[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Declared UpValues, change to Parser. [also Re: explicit mode]
- From: Duane Leslie <parakleta@...>
- Date: Thu, 12 May 2016 10:34:07 +1000
Sorry, sent prematurely...
The example I was starting to write was:
```lua
function a() <_ENV,...>
stmt;*
end
```
is almost equivalent to an unannotated function except that it forces
the `_ENV` upvalue to exist, and forces it to be in the first
position.
The value now is that a function declared as:
```lua
function a() <...>
stmt;*
end
```
Can take whatever upvalues it wants from the locals in its hierarchy
of closures but can never access the implied `_ENV` variable/upvalue.
There can be an argument made that disabling the implied lookup from
the `_ENV` parameter is different to disabling access to the `_ENV`
parameter entirely, but given that any variable or argument with the
name `_ENV` is automatically blessed as the source of globals I don't
think there is any problem similarly treating it as special when
disabling it as an upvalue.
Regards,
Duane.