[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: idea of vision of blueprint of ROADMAP of Lua core
- From: Chris Pressey <cpressey@...>
- Date: Sun, 16 Jan 2005 11:56:47 -0800
On Sun, 16 Jan 2005 12:13:35 +0000
duck <firstname.lastname@example.org> wrote:
> > A way to require (at compile-time) that variables be "declared"
> > (assigned a value) before use, like Perl's 'use strict'.
> See /test/undefined.lua in the 5.0.2 distro for a simple way
> of catching this sort of error, at least after a fashion.
> Not compile-time, but it surely helps...
Thanks for the info, everyone.
For a compile-time solution to this, I pondered it some more after
writing, and came up with the idea of a 'global' keyword, complementing
'local', which tells the compiler that the following variables are
lexically globals - either new ones, in which case 'global' means
something like 'declare', or ones already defined by code that is
compiling this code (by e.g. dofile()), in which case 'global' means
something more like 'import'.
Then just disallow any reference to a variable that hasn't been listed
in either a 'local' or a 'global'.
Looks like the linter does the equivalent of this, though, so it's
probably not necessary in the language itself.