[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: experience implementing a module system
- From: Edgar Toernig <froese@...>
- Date: Wed, 03 May 2000 02:24:29 +0200
Hi,
John Belmonte wrote:
>
> Speaking of orthogonal handling and upvalues, I would like to use the
> upvalue syntax in the global scope. Combined with your patch I could just
> write %var everywhere without having to think about what scope I'm in.
I though about that myself and did not dare to let it behave like that
because I doubt the patch will then ever make it into the standard ;)
You should get this behavior with this additional patch.
(Untested. It just ignores the % in the global scope):
--- lua-4a-upval/src/lparser.c Mon May 1 23:33:39 2000
+++ lua-4a-upval2/src/lparser.c Wed May 3 02:14:16 2000
@@ -272,9 +272,7 @@
FuncState *fs = ls->fs;
int upval = optional(ls, '%');
TString *n = str_checkname(ls);
- if (upval) {
- if (fs->prev == NULL)
- luaX_syntaxerror(ls, "cannot access upvalue in main", n->str);
+ if (upval && fs->prev) {
lookupvar(fs, fs->prev, n, var);
if (var->k == VLOCAL)
luaX_syntaxerror(ls, "cannot access an upvalue in current scope", n->str);
Ciao, ET.