lua-users home
lua-l archive

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

On Sat, 17 Apr 2010 10:12:53 -0600
HyperHacker <> wrote:

> This seems like it should be a simple hack, but I just haven't been
> able to get it to work. I've modified the parser to allow a function
> to be named simply "$" or "@". The intention is to assign them useful
> functions like tostring and tonumber, that take only one argument, to
> create something similar to the # operator but allowing them to be
> redefined if necessary.
> The problem with that idea is you can't just write $foo, only $(foo).
> You can do $"foo", so it seems like it should be simple to extend that
> behaviour to the former case (only for functions named "$" or "@").
> Surprisingly, it doesn't appear to be simple at all.

I'm presently thinking at something maybe a bit similar (not for a Lua variant, rather a custom language). It has 2 aspects:
* Extend Lua-like "funcname {...}" & "funcname '...'" to any argument, and make it standard (and only) func call syntax.
* Identifiers can be made of any non-reserved chars.

It appears to be a bit problematic because of possible ambiguity; especially the case of no arg at all is annoying. So, I ended up using '!' meaning request for execution, eg:
    obj.doSomething arg!
    x : obj.makeSomething arg!
    x : obj.makeSomething!
(This also gives for free a distinction between denotation of the method itself & execution:
    x : obj.makeSomething	<-- 'x' is bound to the method


vit esse estrany ☣