[Omake] Re: variable capture in anonymous functions

Christopher L Conway cconway at cs.nyu.edu
Wed Mar 5 14:08:14 PST 2008


A quick follow-up: I thought maybe this might have something to do
with indentation or the lack thereof, but that's not the case. The
manual says the following three definitions of F should be equivalent,
but they are not: the second two capture X and Y from an enclosing
scope and the first doesn't.

$ cat OMakefile
X = re
Y = flux

F(X, Y) =
   return($(addsuffix $(Y), $(X)))

println( $(F foo, bar) )

F = $(fun X, Y, $(addsuffix $(Y), $(X)))

println( $(F foo, bar) )

F =
   fun(X, Y)
      value $(addsuffix $(Y), $(X))

println( $(F foo, bar) )
$ omake
make[0]: Entering directory `/media/sda6/src/tests/omake/omake.8'
*** omake: reading OMakefiles
foobar
reflux
reflux
*** omake: finished reading OMakefiles (0.01 sec)
*** omake: done (0.02 sec, 0/0 scans, 0/0 rules, 0/33 digests)

Regards,
Chris

On Tue, Mar 4, 2008 at 11:15 PM, Christopher L Conway
<cconway at cs.nyu.edu> wrote:
> I'm seeing variable bindings from the surrounding scope override
>  parameter bindings in anonymous functions. Is there something I am
>  missing about the scoping rules?
>
>  $ cat Omakefile
>  X = zanzi
>
>  apply($(fun X, $(println $(X)bar)), foo)
>  apply($(fun Y, $(println $(Y)bar)), foo)
>
>  $ omake
>  make[0]: Entering directory `/media/sda6/src/tests/omake/omake.8'
>  *** omake: reading OMakefiles
>  zanzibar
>  foobar
>  *** omake: finished reading OMakefiles (0.02 sec)
>  *** omake: done (0.02 sec, 0/0 scans, 0/0 rules, 0/33 digests)
>  $ omake --version
>  OMake 0.9.8.5 (release 2):
>         build [Wed Aug 8 09:10:36 2007]
>         on wagstaff
>
>  Default library directory : /home/chris/tools/lib/omake
>
>  Thanks,
>  Chris
>


More information about the Omake mailing list