[Omake] Further discussion on scoping

Jason Hickey jyh at cs.caltech.edu
Thu Mar 16 18:40:11 PST 2006


I discovered the reason why I was doubtful about naming in function 
bodies while driving:).  But I think it gives a good starting point for 
discussion.

    Overall goal: enhance modularity by preventing inadvertant
       namespace interference between the parts of a project.
    General solution: introduce separate namespaces at the
       file/module level (objects already have separate namespaces).

A lot changed in 0.9.7 to do this.  Functions are a special case, using 
the following policy: unless a variable is already declared statically, 
it is private.  This is safe, but also very conservative.  Consider this

> <jyh:kenai ~/spool/omake 1023>cat a.om
> public.X = 1
> public.printX() =
>    println($"X = $(X)")
> <jyh:kenai ~/spool/omake 1024>cat b.om
> open a
> 
> f() =
>     X = 2
>     printX()
> f()
> 
> X = 3
> printX()
> <jyh:kenai ~/spool/omake 1025>osh b.om
> X = 1
> X = 3

Here, the definition of X in f() is private (because it is not 
statically declared).

This could be surprising!

Jason

-- 
Jason Hickey                  http://www.cs.caltech.edu/~jyh
Caltech Computer Science      Tel: 626-395-6568 FAX: 626-792-4257


More information about the OMake-Devel mailing list