[erlang-questions] Getting rid of the preprocessor

Richard O'Keefe <>
Fri May 25 00:16:33 CEST 2012


On 25/05/2012, at 12:02 AM, Vlad Dumitrescu wrote:

> As one example, how would you parse the following line?
>    ?HELLO(world)


I am no friend of the preprocessor.
But this at least is no new problem:  C has exactly the same
problem, and presumably the C and C++ support in Eclipse
already does something with it.  (If the editor manual is
bigger than the listing of my editor, I don't use it.  Eclipse
massively fails this test, so I don't know much about it.)
I presume it goes something like this:
	if it looks like a variable, display it as one;
	if it looks like a function call, display it as one;
	if the display is wrong, it's the programmer's fault
	for defining such a stupid macro.

There's one possible extra you _might_ want to consider.
I have C macros that would benefit from it.
That is
%%erlide%% begin_like <macro name>
%%erlide%% end_like   <macro name>
so that for example you could use

%%erlide%% begin_like SPAWN
%%erlide%% end_like   END
-define(SPAWN, spawn(fun () ->).
-define(END, end)).
...
   Pid = SPAWN
      Ping!pong,
      Pong!ping
   END,
...

and have it coloured/styled/indented appropriately.




More information about the erlang-questions mailing list