[erlang-questions] One sample program want to know how it works

Zvi exta7@REDACTED
Sun May 18 12:52:03 CEST 2008


what's confusing here is that, as a programmer, you expect following format
for define preprocessor directive:

-define(NAME, VALUE).

Note the closing parenthesis ")" before the dot "."

For strict preprocessor implementation I would expect, this sample to fail
on sytax error. But it's not
So, probably the real format for deine (or attributes in general) is,
either:

-define(NAME, VALUE).

OR

-define(NAME, VALUE .

Then everything is works using substitution:

-define(x,x(.
-define(Xx,X.
-define(X,X)
->. ?x?X?Xx.

SUBSTITUTE:  ?x => "x("

-define(Xx,X.
-define(X,X)
->. x(?X?Xx.

SUBSTITUTE: ?X => "X)\n->"

-define(Xx,X.
x(X)
->?Xx.

SUBSTITUTE: ?Xx => X

x(X) 
-> X.


Zvi


sham wrote:
> 
> -module(xXx).
> -export([x/1]).
> 
> -define(x,x(.
> -define(Xx,X.
> -define(X,X)
> ->. ?x?X?Xx.
> This is the program.I want to know how it works.
> Please anyone help me.
> 
> Thanks&Regards
> Sham.M
> 

-- 
View this message in context: http://www.nabble.com/One-sample-program-want-to-know-how-it-works-tp17274934p17301499.html
Sent from the Erlang Questions mailing list archive at Nabble.com.




More information about the erlang-questions mailing list