Type of expression definition in a schema

Simply put: my question is what type of expression to define in a schema?

Take for example:

(define x 5) 

or

 (define x (lambda (n) (* nn))) 

This is a bit confusing to me. Can anyone help?

+6
source share
1 answer

In Racket, define is a special form, not an expression, so it does not matter per se, if you try to do something like this, you will get an error message:

 (display (define x 42)) => define: not allowed in an expression context in: (define x 42) 

If it were a value, it would be something like void , but it will depend on the specific implementation details of the interpreter (I believe that one translator returned #t after define completed)

The constant #<void> returned by most forms and procedures that have a side effect and do not have a useful result.

the specification does not go into details about this, or - reinforcing the statement that it depends on the implementation.

+11
source

All Articles