lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Yes, true, it would also have to be const. I was just looking at the
example given where the client function follows the foo definition. I
think foo would be linked in a closure here, not a global which could
not be changed.

Const is something I would like to see in Lua but there is an awkward
duality between (in the C sense) static and const. Essentially things
which you want to be const can be pre-processed into the code but this
implies everything is declared. So you start to end up with some
static/dynamic language conflicts.

Nick

> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-
> bounces@bazar2.conectiva.com.br] On Behalf Of Mark Hamburg
> Sent: Wednesday, November 10, 2004 12:21 PM
> To: Lua list
> Subject: Re: Syntax trees, macros, and reflexive Lua evolution
> 
> Adding local could make it work if the type-checker also observed that
it
> was a local that was set only once. Recognizing constant locals seems
like
> it could be interesting for a variety of things in compilation.
> 
> Mark
> 
> on 11/10/04 11:21 AM, Nick Trout at nick@rockstarvancouver.com wrote:
> 
> >
> > I think adding local would make it work though?
> >
> >
> > local function foo() returns string
> >>> return "10";
> >>> end
> >>>
> >>> function foobar() returns number
> >>> return foo(); // illegal, since foo returns string
> >>> end
> >
> >> -----Original Message-----
> >> From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-
> >> bounces@bazar2.conectiva.com.br] On Behalf Of Mark Hamburg
> >> Sent: Wednesday, November 10, 2004 8:15 AM
> >> To: Lua list
> >> Subject: Re: Syntax trees, macros, and reflexive Lua evolution
> >>
> >> The type-checking won't work in your example because foo might get
> >> redefined
> >> before being called by foobar.
> >>
> >> Mark
> >>
> >> on 11/9/04 9:59 PM, Quinn Tyler Jackson at quinn-j@shaw.ca wrote:
> >>
> >>> This could also be used for simple type checking:
> >>>
> >>> function foo() returns string
> >>> return "10";
> >>> end
> >>>
> >>> function foobar() returns number
> >>> return foo(); // illegal, since foo returns string
> >>> end
> >