Reputation: 15
I was trying to run this command on drracket:
(define #t #f)
and I get the following error messege:
define: bad syntax in: #t
I want to know what's the reason for that error, and why I can do: (define + 12)
and not this.
Thanks a lot!
Upvotes: 2
Views: 199
Reputation: 134255
define
expects an identifier as it's first argument. In this case you are supplying #t
which evaluates to the boolean value true. Hence the bad syntax
error message.
Upvotes: 0
Reputation: 223183
The syntax of define
is:
(define <variable> <expression>)
A variable is a special kind of identifier, and the format of identifiers is described here. As you can see from the description, #t
(and more generally, anything that starts with a #
) is not an identifier.
Upvotes: 4
Reputation: 18409
First argument to define
must be a symbol. +
is a symbol. foo
is a symbol. #t
is #t, not a symbol. 1
is not a symbol.
Upvotes: -2