[erlang-questions] -define

Ulf Wiger <>
Thu Feb 18 12:01:29 CET 2010


----- "Robert Virding" <> wrote:

> There is a simple reason for this: sheer laziness by the original
> writer of the epp module, me. Now I suppose it is difficult to change
> because of backwards compatibility. The problem is compounded byt the
> feature that macro expansions don't have to be complete erlang
> expressions so sometimes you can't tell the macro definition is over
> until you hit the '.' .

Well, if you look at the source in epp.erl, it doesn't seem to
be that difficult to change:

macro_expansion([{')',_Lp},{dot,_Ld}]) -> [];
macro_expansion([{dot,_Ld}]) -> []; %Be nice, allow no right paren!
macro_expansion([T|Ts]) ->    [T|macro_expansion(Ts)].

It ought to be enough to delete the line with the "Be nice" comment,
or perhaps modify it to signal an error instead.

BR,
Ulf W

> 
> Robert
> 
> On 18 February 2010 06:32, Richard O'Keefe <> wrote:
> > I've been trying out a weak pretty-printer for Erlang.
> > (By "weak" I mean that it takes care of indentation but
> > does not do anything about line breaking.)  It's supposed
> > to be something I can build into my text editor.
> >
> > When I tried feeding other people's Erlang code into it,
> > I ran into some problems.
> >
> > I was aware that when you write
> >
> >        -define(LHS, RHS).
> >
> > the stuff in RHS did not have to be bracket balanced, so
> > that
> >        -define(LP, ().
> >        -define(RP, )).
> >
> > are OK.
> > What I was *not* aware of was that there doesn't even have
> > to be a closing right parenthesis at all.
> >
> > -module(ick).
> > -export([ick/0]).
> > -define(ICK, {1}.
> >
> > ick() -> ?ICK.
> >
> > The Erlang compiler is perfectly happy with this.
> > There are several occurrences of this in the Erlang/OTP sources,
> > but there doesn't seem to be any reason why.
> >
> >
> >
> > ________________________________________________________________
> > erlang-questions (at) erlang.org mailing list.
> > See http://www.erlang.org/faq.html
> > To unsubscribe; mailto:
> >
> >
> 
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:

-- 
Ulf Wiger
CTO, Erlang Training & Consulting Ltd.
http://www.erlang-consulting.com
---------------------------------------------------

---------------------------------------------------

WE'VE CHANGED NAMES!

Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.

www.erlang-solutions.com



More information about the erlang-questions mailing list