problems with if

45 views
Skip to first unread message

raschedh

unread,
Jan 26, 2012, 5:16:33 PM1/26/12
to Clojure
Hello, world !

Because that is my first post, I can not resist to say
"Thank you !!!" for clojure. I like it at lot.

When I type

(if true "t" f)

in a fresh REPL, I get the error

[...] Unable to resolve symbol: f [...]

But my interpretation of the reference ( http://clojure.org/special_forms#if
) is,
that, in the above case, f should not have been evaluated at all.

In scheme (I use mit-scheme) and in common-lisp (I use clisp) I get
the
(expected) behaviour:

In common lisp, for example:

(if t "t" f)
evaluates to "t".

Only when I do

(if nil "t" f)

I get the (expected) error, that f has got no value.

So, why is Clojure trying to resolve the symbol f ?
What do I not understand ?

In happens in clojure 1.3.0 as well as in a fresh build from the git
repo.

Thanks four your help.

Heinz.

Cedric Greevey

unread,
Jan 27, 2012, 10:44:09 AM1/27/12
to clo...@googlegroups.com
On Thu, Jan 26, 2012 at 5:16 PM, raschedh <rasc...@gmail.com> wrote:
> Hello, world !
>
> Because that is my first post, I can not resist to say
> "Thank you !!!" for clojure. I like it at lot.
>
> When I type
>
> (if true "t" f)
>
> in a fresh REPL, I get the error
>
> [...] Unable to resolve symbol: f [...]

Unlike in Common Lisp, Clojure resolves symbols at compile time.

Roman Perepelitsa

unread,
Jan 27, 2012, 10:44:03 AM1/27/12
to clo...@googlegroups.com
2012/1/26 raschedh <rasc...@gmail.com>
(if true "t" f)

in a fresh REPL, I get the error

[...] Unable to resolve symbol: f [...]

In common lisp, for example:

(if t "t" f)
evaluates to "t".

Try (if t "t" blah) in common lisp, you'll get the same error.

Roman Perepelitsa.

Roman Perepelitsa

unread,
Jan 27, 2012, 10:50:43 AM1/27/12
to clo...@googlegroups.com
2012/1/27 Roman Perepelitsa <roman.pe...@gmail.com>

Try (if t "t" blah) in common lisp, you'll get the same error.

I just tried it and it resolves to "t" in Common Lisp. Sorry about that :-/

Cedric's reply is the one you are looking for.

Roman Perepelitsa.

raschedh

unread,
Jan 28, 2012, 10:55:56 AM1/28/12
to Clojure
> Unlike in Common Lisp, Clojure resolves symbols at compile time.

Thank you, for stating this fact so precisely, thereby answering
my question.

I do have difficulties, though, to deduce this fact from the
reference manual.
But, well, there you go.

Heinz.
Reply all
Reply to author
Forward
0 new messages