1 Welcome to PLT Scheme
2 Scheme Essentials
3 Built-In Datatypes
4 Expressions and Definitions
5 Programmer-Defined Datatypes
6 Modules
7 Input and Output
8 Contracts
9 Classes and Objects
10 Exceptions and Control
11 Iterations and Comprehensions
12 Regular-Expression Matching (Regexps)
13 Pattern Matching
14 Quasiquoting
15 Units (Higher-Order Modules)
16 Threads
17 Syntactic Extension (Macros)
18 Reflection and Dynamic Evaluation
19 Reader Extension
20 Security
21 Memory Management
22 Performance
23 Foreign-Function Interface (FFI)
24 Scripts
25 Graphical User Interfaces (GUIs)
26 More Tools
Index

contents

 index

← prev  up  next →

 

3.12 Void and Undefined

Some procedures or expression forms have no need for a result value. For example, the display procedure is called only for the side-effect of writing output. In such cases the reslt value is normally a special constant that prints as #<void>. When the result of an expression is simply #<void>, the REPL does not print anything.

The void procedure takes any number of arguments and returns #<void>. (That is, the identifier void is bound to a procedure that returns #<void>, instead of being bound directly to #<void>.)

Examples:

  > (void)

  > (void 1 2 3)

  > (list (void))

  (#<void>)

A constant that prints as #<undefined> is used as the result of a reference to a local binding when the binding is not yet initialized. Such early references are not possible for bindings that corerspond to procedure arguments, let bindings, or let* bindings; early reference requires a recursive binding context, such as letrec or local defines in a procedure body. Also, early references to top-level and module-level bindings raise an exception, instead of producing #<undefined>. For these reasons, #<undefined> rarely appears.

  (define (strange)

    (define x x)

    x)

  > (strange)

  #<undefined>

 

contents

 index

← prev  up  next →