[erlang-questions] Getting rid of the preprocessor
Thu May 24 14:02:32 CEST 2012
On Thu, May 24, 2012 at 1:44 PM, Max Bourinov <bourinov@REDACTED> wrote:
> I have relatively big OTP system. I use macros. I don't have any problems
> you described. What I do wrong?
If you have no problems, then you do nothing wrong! :-)
> I don't debug my code because I think debugging is bad. I do unit tests and
> ct tests. If after those tests there is a need for debug - my tests are bad.
> I do better tests. Will this approach work for you too?
Yes, I know about that. But there is a debugger and if someone wants
to use it, it should be as useful as possible.
I have problems with macros because I am working on erlide [*] which
like any IDE that uses the source files and needs also to be as useful
as possible by providing editing help. Source files with
non-restricted macros can't be parsed with normal parsers. Even
putting restrictions on the macro values so that they are well-behaved
requires a context-dependent parsing.
As one example, how would you parse the following line?
The answer is that it depends.
With -define(HELLO, hello), it is a function call to hello(world).
With -define(HELLO(Arg), whatever), it is whatever the macro value is.
This could be disambiguated by requiring all macro references to be
followed by parentheses, like function calls, but that would be
massively not backwards-compatible.
[*] Eclipse based IDE, http://erlide.org
More information about the erlang-questions