[erlang-questions] Getting rid of the preprocessor
Mon May 28 10:07:38 CEST 2012
Thank you for the answer, Richard.
On Mon, May 28, 2012 at 12:40 AM, Richard O'Keefe <> wrote:
> If two modules need to use the same record,
> the definition is put in a .hrl file
> and each module -includes that file.
> This inclusion is done by the preprocessor.
Yes. So if the preprocessor only does inclusions and ifdefs (which
don't affect the structure of the code because they only work outside
form definitions), then "clean macros" could be part of the language
proper (with a suitable list of restrictions on what they could
resolve to). I can even imagine that a macro that isn't clean (value
can't be parsed standalone) may be still handled as today, during a
period of transition.
> I find myself working on code that isn't _finished_ yet most of the
> time, for which there _are_ as yet no facts of the matter on which
> an IDE could depend.
Why not? Even if the current module is not finished, you can still
know things about the other modules and about the entities in this
module that can be parsed.
An IDE can also help find problems before runtime, because it knows
about the whole code base while the compiler only handles one module
at a time. If I know I am not using weird meta-programming techniques
and I refer to a "foo:bar/3" where foo is in my project and bar/3
doesn't exist, I'd like to get a warning about that. The tests will
probably catch that, but this is faster.
> If memory serves me, the way Quintus handled
> the Emacs interface was for Emacs to ask Prolog to do the parsing.
That's what we do today, we use the Erlang scanner and parser. Problem
is that they know nothing about macros, so we need to do manual magic.
There are problems with having to talk to an Erlang node all the time
like this (loss of synchronization, etc), so we are now moving to a
Java-based parser. The disadvantage of that one is that we can't do
any magic, so we have to be able to parse as much as possible.
> I for one do not expect "meaningful completions" for macros.
For example, "?DE<tab>" will complete to "?DEBUG" or give a list with
"?DEBUG" and "?DELETE".
>> The parser grammar is basically describing this nice language, except
>> that any grammar construct or combination thereof may be represented
>> by a macro call...
> The difficulty is acknowledged. As is the fact that you can't stop
> people using a processor even if there is none in the language. I
> have Smalltalk code generated using m4(1) and awk(1). The Smalltalk+m4
> source code has to be edited *somehow*.
Yes, but if they do that, they habe basically a new language and are
on their own, just like if they are using LFE, Elixir or Reia. I am
talking about the base language.
More information about the erlang-questions