Thanks Richard for your response. That makes sense.<div><br></div><div>Actually what I wanted is to get a macro expand into two different functions in the source file. My intention was not producing a term. That is where the '.' came to be a problem.</div>
<div><br></div><div>It seems it not possible. Anyways I will breakdown the macro into two different ones.</div><div><br></div><div>Kind Regards,</div><div>Kannan.</div><div><br><br><div class="gmail_quote">On Wed, May 30, 2012 at 3:58 PM, Richard Carlsson <span dir="ltr"><<a href="mailto:carlsson.richard@gmail.com" target="_blank">carlsson.richard@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 05/30/2012 12:17 PM, Kannan wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Also, is there a way to expand a single macro into multiple macros,<br>
before a final replacement?<br>
</blockquote>
<br></div>
If you mean into multiple macro definitions, it is not possible - each macro definition is a separate form, and you can't expand one form into multiple forms. But multiple uses of macros in the body of another macro is not a problem, if that's what you mean:<br>
<br>
-define(X, {foo, ?Y, ?Z}).<br>
<br>
/Richard<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On Wed, May 30, 2012 at 3:42 PM, Kannan <<a href="mailto:vasdeveloper@gmail.com" target="_blank">vasdeveloper@gmail.com</a><br></div><div class="im">
<mailto:<a href="mailto:vasdeveloper@gmail.com" target="_blank">vasdeveloper@gmail.com</a><u></u>>> wrote:<br>
<br>
My bad, please read the second PP as -define.<br>
<br>
<br>
On Wed, May 30, 2012 at 3:41 PM, Kannan <<a href="mailto:vasdeveloper@gmail.com" target="_blank">vasdeveloper@gmail.com</a><br></div><div class="im">
<mailto:<a href="mailto:vasdeveloper@gmail.com" target="_blank">vasdeveloper@gmail.com</a><u></u>>> wrote:<br>
<br>
Isn't PP takes place before parsing? Isn't PP is simply a string<br>
replacement?<br>
<br>
<br>
<br>
On Wed, May 30, 2012 at 3:03 PM, Richard Carlsson<br></div>
<<a href="mailto:carlsson.richard@gmail.com" target="_blank">carlsson.richard@gmail.com</a> <mailto:<a href="mailto:carlsson.richard@gmail.com" target="_blank">carlsson.richard@<u></u>gmail.com</a>>><div class="im">
<br>
wrote:<br>
<br>
On 05/30/2012 11:26 AM, Kannan wrote:<br>
<br>
Hi There,<br>
<br>
If -define does just string replacement, why it does not<br>
let me do the<br>
following?<br>
<br>
-define(Z, z() -> io:fwrite("z")).<br>
-define(Y, y() -> io:fwrite("y")).<br>
-define(X, ?Y. ?Z.).<br>
<br>
<br>
In the last line, you have ?Y. followed by whitespace. This<br>
ends the define declaration. Erlang source code is divided<br>
into "forms", where each form ends with . followed by<br>
whitespace (usually newline, but any whitespace or even a<br>
comment can be used). So you have two forms at the end:<br>
'-define(X, ?Y.' and '?Z.).' and none of these are<br>
syntactically valid. It is not possible to make a single<br>
macro expand into two forms.<br>
<br>
/Richard<br>
<br>
<br>
<br>
<br>
</div></blockquote>
<br>
</blockquote></div><br></div>