lua-users home
lua-l archive

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




On Saturday, June 6, 2015, Brigham Toskin <brighamtoskin@gmail.com> wrote:
Yeah, this feels more like Ruby. Not a bad thing per se, but Ruby's grammar is designed to take this into account with minimal ambiguity.

Agreed. 

Ruby uses lines as statement separators (or explicit backslash or binary operator or any other explicit notation to extend into the second line). On the other hand, Lua uses spaces. Not the point of which is preferable, but those two syntactical differences shouldn't try to reconcile each other only for the sake of syntax sugary. 


 

On Sat, Jun 6, 2015 at 2:47 PM, Nagaev Boris <bnagaev@gmail.com> wrote:
On Sat, Jun 6, 2015 at 9:33 PM, Rodrigo Azevedo <rodrigoams@gmail.com> wrote:
> 3.4.10 – Function Calls
>
> The form
>
> functioncall ::= prefixexp ‘:’ Name args
>
> Arguments have the following syntax:
>
> args ::= ‘(’ [explist] ‘)’
> args ::= tableconstructor
> args ::= LiteralString
>
> can be used to call "methods". A call v:name(args) is syntactic sugar for
> v.name(v,args), except that v is evaluated only once.
>
> -------------------
>
> Let v be a usardata with a unary method, then
>
> v:abs() is a syntatic sugar for v.abs(v)
> v:reduce() is a syntatic sugar for v.reduce(v)
>
> etc
>
> This notation is very unpleasant. There is a problem if this behaviour of
> function calls
>
> v:abs is a syntativ sugar for v.abs(v)
> v:reduce is a syntatic sugar for v.reduce(v)
>
> was valid?
>
> If not, I really appreciate this new flavor.
>
> --
> Rodrigo Azevedo Moreira da Silva

1. Notation v:abs would create a special case, that is why it should be avoided.

2. v:abs can be ambiguous:

  v:abs
  (a)

Is it

1) v:abs(a)
 or
2) v:abs(); (a)

?

3. Personally, I'd prefer v:abs(). v:abs doesn't look like a call.

PS. Look into moonscript.

--


Best regards,
Boris Nagaev




--
Brigham Toskin