[erlang-questions] Erlang PP Question
Wed May 30 12:23:27 CEST 2012
On 05/30/2012 12:11 PM, Kannan wrote:
> Isn't PP takes place before parsing? Isn't PP is simply a string
Almost - it's token level replacement (just as in the C preprocessor),
and the splitting into forms is done before preprocessing.
> On Wed, May 30, 2012 at 3:03 PM, Richard Carlsson
> < <mailto:>> wrote:
> On 05/30/2012 11:26 AM, Kannan wrote:
> Hi There,
> If -define does just string replacement, why it does not let me
> do the
> -define(Z, z() -> io:fwrite("z")).
> -define(Y, y() -> io:fwrite("y")).
> -define(X, ?Y. ?Z.).
> In the last line, you have ?Y. followed by whitespace. This ends the
> define declaration. Erlang source code is divided into "forms",
> where each form ends with . followed by whitespace (usually newline,
> but any whitespace or even a comment can be used). So you have two
> forms at the end: '-define(X, ?Y.' and '?Z.).' and none of these are
> syntactically valid. It is not possible to make a single macro
> expand into two forms.
More information about the erlang-questions