lua-users home
lua-l archive

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


2010/4/19 spir ☣ <denis.spir@gmail.com>:
> On Mon, 19 Apr 2010 01:05:58 -0400
> Henk Boom <henk@henk.ca> wrote:
>> One controversial alternative: instead of using '!' use '\n'.
>>
>>     henk
>
> Are you joking? Anyway...
> * How can one chain calls, eg having the result of a query be the argument of a command?
>    console.write list.sort!!
>  (same issue for having a query result nearly anywhere in a compound expression)
> * In a rather extreme variant of my project, there cannot be any complex expression, so one would write the above in two steps.

Sorry, I misunderstood '!' as being a statement separator.

Looking at the example of

console.write list.sort!!

Which of the following does it represent? How would you write the other?

console.write(list.sort())
console.write(list.sort)()

With the following:
a b!
a b!

would it turn into:

a(b)
a(b)

or would it be more like "a b! a b!" which more intuitively becomes:

a(b)(a(b))

---
Haskell uses the implicit-function-call syntax you're writing, and it
gets around a lot of these problems by being purely functional, which
has the side effects that:

- there is no difference between a function which takes no arguments
and a regular value (i.e. no difference between "function () return 1
end" and "1")
- there are no statements, only expressions

Also, the fact that all Haskell functions are "actually" of arity 1 helps :)

I think OCaml also has a similar syntax too, but I don't know enough
about it to be able to say anything useful.

    henk