lua-users home
lua-l archive

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


> The "@" trick does help here, it decides weather to use "." or ":" based on
> the first non space character after the identifier that follows "@". If it's
> a "(", use ":" else use ".".

Careful there. Consider the following issues:

1. Lua allows a function call in the form "function table-constructor" or "function string-literal". This shouldn't be too hard to handle; just make sure that { or " or [[ (not [[--) trigger the :. (I don't think I've ever used so much punctuation in one sentence)

2. (more tricky) keep in mind that objects may want to store references to external functions in member variables (for callbacks and suchlike). Seems like the @@ syntax would work here; just make sure to explicitly document that it's for more than just static functions.

You might also consider, instead of a preprocessor, patching the lua parser; it may be the simplest way to handle subtle issues such as nested block comments and other special cases. It would also undoubtedly be more tightly integrated with the compiler, allowing a single source for syntax error messages. I have to admit, though, that my suggestion is not entirely selfless; I've been meaning to patch the parser for my own uses for some time, and would be extremely interested to hear the experiences of others in working with that code.

Ben