lua-users home
lua-l archive

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


2018-07-02 8:33 GMT+02:00 Axel Kittenberger <axkibe@gmail.com>:
>> Feature detection is sometimes more actionable than version detection.
>
> I second this.
>
> First while this is a nice puzzle / brain teaser, I'd discourage anyone from
> actually doing such thing in production code. First like Pierre said, if you
> are detecting behaviour/ features it's all cool, just leave the switches
> that way instead of projecting them on version numbers.
>
> Secondly, this code is not future safe at all. For example Lua 6.0 might
> detect as 5.1, who knows.
>
> Lastly if you don't trust the environment you are run in, you already lost
> by the overall design concept.

I must come to Egor's aid here. Just as in Chess some people use the
rules of Chess simply in order to compose problems and endgame
studies, Egor sets Lua tasks. (He also does code golf in Lua.) This
one is "write code that behaves differently for every Lua version
without relying on any preloaded global variable".

It is not necessary that the code is good for any practical purpose.
The appeal lies in the ingenuity and neatness of the answer.