[erlang-questions] Getting rid of the preprocessor
Thu May 24 14:38:35 CEST 2012
You are right, it is nearly impossible to properly work with macros in
IDE. I never tried erlide. Does it give any coding performance boost? I use
sublime2 and emacs. Most of Erlangers uses Emacs (as far as I know).
About your example: You can agree within your team which macros you will
use and which not. For example:
1. No complicated code snippets in macros - this is good for code
2. All atoms that are flying between modules must be in macros. Or even
better - use records for that.
Simple rules - simple code. Macros are good. They are cool. Use right tool
and you have no problems.
On Thu, May 24, 2012 at 4:02 PM, Vlad Dumitrescu <vladdu55@REDACTED> wrote:
> Hi Max,
> 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
> > ct tests. If after those tests there is a need for debug - my tests are
> > 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions