lua-users home
lua-l archive

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


On Tue, Jul 5, 2011 at 12:00 PM, HyperHacker <hyperhacker@gmail.com> wrote:
> On Mon, Jul 4, 2011 at 15:58, Alexander Gladysh <agladysh@gmail.com> wrote:
>> On Tue, Jul 5, 2011 at 00:19, David Manura <dm.lua@math2.org> wrote:
>>> On Mon, Jul 4, 2011 at 3:40 PM, Luiz Henrique de Figueiredo
>>> <lhf@tecgraf.puc-rio.br> wrote:
>>>> Lua 5.2.0 (beta-rc5) is now available [...]
>>>>        - clarifications between 'deprecated' and 'removed'
>>
>>> This way of removing functions might not be ideal:
>>
>> I second this.
>>
>>>  stdin:1: 'popen' not supported
>>>  stack traceback:
>>>        [C]: in function 'popen'
>>>        stdin:1: in main chunk
>>>        [C]: in ?
>>
>> While this one *may* be justified...
>>
>>>  > setfenv(function()end, {})
>>>  stdin:1: deprecated function
>>>  stack traceback:
>>>        [C]: in function 'setfenv'
>>>        stdin:1: in main chunk
>>>        [C]: in ?
>>
>> ...This one, IMO, makes no sense. If it is deprecated, it must work.
>> Otherwise it is removed (and replaced with nonsense stub).
>>
>> My opinion is that there must be a clear way to programmatically
>> determine a capability list of the given Lua interpreter. The best way
>> to do this — is to actually *remove* removed functions.
>>
>> Uninitiated Lua 5.2 users would google up the "setfenv, attempted to
>> call a nil value" (or whatever) error message, and would get the
>> reason why this happens and what to do on the first hit. (One way to
>> guarantee this — is to create a quality set question+answer pairs on
>> the subject on StackOverflow.)
>>
>> My 2c,
>> Alexander.
>>
>>
>
> Hm, I was thinking of something like this:
> local deleted = setmetatable({}, {
> __call = function() error("This function no longer exists") end,
> __eq = function(self, other) return not other end,
> })
>
> That would allow you to test if the function exists, and still get a
> "removed" error if you call it. However it seems __eq doesn't trigger
> when comparing to nil...
> Of course, you can do "if somefunc == deleted" instead...
>
> --
> Sent from my toaster.
>
>

That seems like over-designing a simple problem.

Removing the functions properly, and providing a compat / warning
library that re-defines the missing pieces seems much cleaner and more
useful to me.