lua-users home
lua-l archive

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


On Wed, Jun 6, 2018 at 12:37 AM, dyngeccetor8 <dyngeccetor8@disroot.org> wrote:

> But why it is inconsistent? From my view that functions is logically  correct.

Because it is incomplete, it is difficult to say why exactly it is inconsistent. A few things that seemed odd to me:

1. Lua describes 'and' and 'or' is binary operator Your description had variadic functions, so they can be called with zero, one or more than two arguments, and what does that mean? Fundamentally, Lua ensures that 'and' and 'or' have exactly two operands statically, your description cannot do that. 

2. The or-function seemed prone to infinite recursion if called without arguments.

3. In order to have short-circuit operation your functions would need to receive their arguments not as pre-evaluated values of "operands", but rather as functions computing those values. Ignoring that this is syntactically very different from true 'and' and 'or', the treatment of the first argument was still like that of a pre-evaluated value, rather than a value-producing function.

Cheers,
V.