PREV UP NEXT SCM

4.9: Low Level Syntactic Hooks

Callback procedure: read:sharp c port
If a # followed by a character (for a non-standard syntax) is encountered by read, read will call the value of the symbol read:sharp with arguments the character and the port being read from. The value returned by this function will be the value of read for this expression unless the function returns #<unspecified> in which case the expression will be treated as whitespace. #<unspecified> is the value returned by the expression (if #f #f).

Note: When adding new # syntaxes, have your code save the previous value of read:sharp when defining it. Call this saved value if an invocation's syntax is not recognized. This will allow #+, #-, #!, and Uniform Arrays to still be supported (as they use read:sharp).

Function: procedure->syntax proc
Returns a macro which, when a symbol defined to this value appears as the first symbol in an expression, returns the result of applying proc to the expression and the environment.
Function: procedure->macro proc
Function: procedure->memoizing-macro proc
Returns a macro which, when a symbol defined to this value appears as the first symbol in an expression, evaluates the result of applying proc to the expression and the environment. The value returned from proc which has been passed to PROCEDURE->MEMOIZING-MACRO replaces the form passed to proc. For example:
(define trace
  (procedure->macro
   (lambda (x env) `(set! ,(cadr x) (tracef ,(cadr x) ',(cadr x))))))

(trace foo) == (set! foo (tracef foo 'foo)).

An environment is a list of environment frames. There are 2 types of environment frames:

((lambda (variable1 ...) ...) value1 ...)
(let ((variable1 value1) (variable2 value2) ...) ...)
(letrec ((variable1 value1) ...) ...)
result in a single enviroment frame:
((variable1 ...) value1 ...)
(let ((variable1 value1)) ...)
(let* ((variable1 value1) ...) ...)
result in an environment frame for each variable:
(variable1 . value1) (variable2 .  value2) ...
Special Form: @apply procedure argument-list
Returns the result of applying procedure to argument-list. (apply procedure argument-list) will produce the same result.
Special Form: @call-with-current-continuation procedure)
Returns the result of applying procedure to the current continuation. A continuation is a SCM object of type contin (see Continuations). The procedure (call-with-current-continuation procedure) is defined to have the same effect as (@call-with-current-continuation procedure).