lua-users home
lua-l archive

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

On 2015-07-17 5:56 AM, Pierre Chapuis wrote:
On Thu, Jul 16, 2015 at 4:00 PM, Tim Caswell <> wrote:
This is one of those areas where languages without infix notation, but
variable-length arguments (like lisp) smile.  You can just do (< x y z)
it will do what you expect or (< (<x y) z) to simulate the lua

But then you have to give up infix notation and/or have crazy
like {x < y < z} means to transform to (< x y z) if curly braces are
and every odd symbol is the same.
It's also possible to do it at the grammar level, defining the
comparison operators as being optionally ternary.
If you allow that, you probably also want to allow x < y <= z and the like.

I don't think the complexity is really worth it, but if a language is
going to support such things it could go further and do something like:

     if y in ]x,z] then

which would also work with things like:

     if y in {3, 5, 7, 9} then

I don't think Lua is or should be that language though :)

  if y in ]x,z] then  is more saying   if y in include in aRangeObject

now introducing Range, can be alot more fun ...  and complex :o),
ranges can be use for ..

range tests, enumerator in some forloop, initialization, indexing array/table ... (check few with python)
beside be use for numbers, int, float, letters(remind pattern a-zA-Z) ...

can range be extent to be use a 2 dimensions (or n dimensions) ?
ex. range for complex number?  can be a line between the 2 numbers, or a rectangle of values between them (now this is more like a constrain domain)...

range or domain of constrain fct ? [ f(x), f(y) ]