Re: Closures and subs

2004-11-05 Thread Piers Cawley
Leopold Toetsch <[EMAIL PROTECTED]> writes: > Piers Cawley <[EMAIL PROTECTED]> wrote: >> Leopold Toetsch <[EMAIL PROTECTED]> writes: > >>> Klaas-Jan Stol <[EMAIL PROTECTED]> wrote: Hello, >>> I've been playing with closures and subs but I have a little bit of trouble with those. >>>

Re: Closures and subs

2004-11-05 Thread Leopold Toetsch
Piers Cawley <[EMAIL PROTECTED]> wrote: > Leopold Toetsch <[EMAIL PROTECTED]> writes: >> Klaas-Jan Stol <[EMAIL PROTECTED]> wrote: >>> Hello, >> >>> I've been playing with closures and subs but I have a little bit of >>> trouble with those. >> >> newsub $P0, .Closure, _foo >> $P0

Re: Closures and subs

2004-11-04 Thread Piers Cawley
Leopold Toetsch <[EMAIL PROTECTED]> writes: > Klaas-Jan Stol <[EMAIL PROTECTED]> wrote: >> Hello, > >> I've been playing with closures and subs but I have a little bit of >> trouble with those. > > newsub $P0, .Closure, _foo > $P0(q) > newsub $P0, .Closure, _foo >

Re: Closures and subs

2004-11-04 Thread Leopold Toetsch
Klaas-Jan Stol <[EMAIL PROTECTED]> wrote: > Thanks for your quick reactions. You are welcome. > Indeed, doing > $P0(q) > works ok. I'm a bit confused by syntax then (but I think it makes sense > now, if IMCC sees the "(", it is expecting args I guess) Yep. Function and method calls as well a

Re: Closures and subs

2004-11-04 Thread Klaas-Jan Stol
I now see I made some errors (I explain below) First, I show the Lua code: function newCounter () local i = 0 return function () -- anonymous function i = i + 1 return i end end c1 = newCounter() print(c1()) --> 1 print(c1()) --> 2 This is the translation (and it works! :-) .sub _

Re: Closures and subs

2004-11-04 Thread Luke Palmer
I haven't written PIR in a while, and I'm not terribly familiar with the new changes, but I'll make some guesses. Klaas-Jan Stol writes: > function main() > >local p = 123; >local q = 345; > >foo(q); >foo(q); > >function foo(a) # nested function, it does have access to

Re: Closures and subs

2004-11-04 Thread Klaas-Jan Stol
Leopold Toetsch wrote: Klaas-Jan Stol <[EMAIL PROTECTED]> wrote: Hello, I've been playing with closures and subs but I have a little bit of trouble with those. newsub $P0, .Closure, _foo $P0(q) newsub $P0, .Closure, _foo $P0(q) Closures have to be distinct. leo Tha

Re: Closures and subs

2004-11-04 Thread Leopold Toetsch
Klaas-Jan Stol <[EMAIL PROTECTED]> wrote: > Hello, > I've been playing with closures and subs but I have a little bit of > trouble with those. newsub $P0, .Closure, _foo $P0(q) newsub $P0, .Closure, _foo $P0(q) Closures have to be distinct. leo

Re: Closures and subs

2004-11-03 Thread Sam Ruby
Klaas-Jan Stol wrote: Hello, I've been playing with closures and subs but I have a little bit of trouble with those. I'm a bit confused by all different flavours of syntax, I've been trying to read and understand all documents concerning this subject, the most useful was reading the test scripts