lua-users home
lua-l archive

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


I would guess the way to approach this is to define @ and $ as operators which compile into the desired function calls.

Tony (on his iPod).
--
f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/


On 17 Apr 2010, at 17:12, HyperHacker <hyperhacker@gmail.com> 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.
Is there anyone more familiar with the source that might be able to do
this? Could this idea be generalized into being able to define custom
operators which simply call metamethods on their single argument?

--
Sent from my toaster.