[erlang-questions] quote, backquote and unquote in Erlang

Jeff Rogers dvrsn@REDACTED
Mon Jun 25 22:20:11 CEST 2007


Burkhard Neppert wrote:
>  Hello,
> 
> I'm new to Erlang and have a little lisp/scheme experience. Is there a 
> way to do the same thing
> like scheme's quote, quasiquote (aka backquote) and unquote in Erlang?

quote for the most part isn't necessary, since atoms aren't evaluated - 
they represent just themselves and not some other value.

(define Var 'value)

just translates as

Var = value.

If you are finding it necessary to create atoms that do not conform to 
the normal atom naming rules (starts with lowercase, no funny 
characters), you can use '' to create such a nonstandard atom.

Var = 'Some weird atom'.

quasiquote/unquote I'm less certain of due to my lack of scheme 
experience, but again since erlang doesn't evaluate every term it 
doesn't seem like it is needed.

(define Var 'world)
`(hello ,Var)

is roughly the same as

Var = world,
[hello, Var].

I suspect ` is used by schemers for much more complex and powerful 
constructs, but without seeing the use its hard to say how to translate it.

-J



More information about the erlang-questions mailing list