mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-02 13:00:26 +02:00
(Expression Syntax): Turned syntax description into a table, @deffn is
not really up to the task.
This commit is contained in:
parent
9b792a7ec0
commit
a8551448a3
1 changed files with 19 additions and 18 deletions
|
@ -40,7 +40,9 @@ loading and evaluating Scheme code at run time.
|
||||||
|
|
||||||
An expression to be evaluated takes one of the following forms.
|
An expression to be evaluated takes one of the following forms.
|
||||||
|
|
||||||
@deffn syntax <symbol> {}
|
@table @nicode
|
||||||
|
|
||||||
|
@item @var{symbol}
|
||||||
A symbol is evaluated by dereferencing. A binding of that symbol is
|
A symbol is evaluated by dereferencing. A binding of that symbol is
|
||||||
sought and the value there used. For example,
|
sought and the value there used. For example,
|
||||||
|
|
||||||
|
@ -48,9 +50,8 @@ sought and the value there used. For example,
|
||||||
(define x 123)
|
(define x 123)
|
||||||
x @result{} 123
|
x @result{} 123
|
||||||
@end example
|
@end example
|
||||||
@end deffn
|
|
||||||
|
|
||||||
@deffn {syntax} {} (proc [args @dots{}])
|
@item (@var{proc} @var{args}@dots{})
|
||||||
A parenthesised expression is a function call. @var{proc} and each
|
A parenthesised expression is a function call. @var{proc} and each
|
||||||
argument are evaluated, then the function (which @var{proc} evaluated
|
argument are evaluated, then the function (which @var{proc} evaluated
|
||||||
to) is called with those arguments.
|
to) is called with those arguments.
|
||||||
|
@ -69,9 +70,8 @@ The same sort of parenthesised form is used for a macro invocation,
|
||||||
but in that case the arguments are not evaluated. See the
|
but in that case the arguments are not evaluated. See the
|
||||||
descriptions of macros for more on this (@pxref{Macros}, and
|
descriptions of macros for more on this (@pxref{Macros}, and
|
||||||
@pxref{Syntax Rules}).
|
@pxref{Syntax Rules}).
|
||||||
@end deffn
|
|
||||||
|
|
||||||
@deffn syntax <constant>
|
@item @var{constant}
|
||||||
Number, string, character and boolean constants evaluate ``to
|
Number, string, character and boolean constants evaluate ``to
|
||||||
themselves'', so can appear as literals.
|
themselves'', so can appear as literals.
|
||||||
|
|
||||||
|
@ -85,10 +85,9 @@ themselves'', so can appear as literals.
|
||||||
|
|
||||||
Note that an application must not attempt to modify literal strings,
|
Note that an application must not attempt to modify literal strings,
|
||||||
since they may be in read-only memory.
|
since they may be in read-only memory.
|
||||||
@end deffn
|
|
||||||
|
|
||||||
@deffn syntax quote data
|
@item (quote @var{data})
|
||||||
@deffnx syntax ' data
|
@itemx '@var{data}
|
||||||
Quoting is used to obtain a literal symbol (instead of a variable
|
Quoting is used to obtain a literal symbol (instead of a variable
|
||||||
reference), a literal list (instead of a function call), or a literal
|
reference), a literal list (instead of a function call), or a literal
|
||||||
vector. @nicode{'} is simply a shorthand for a @code{quote} form.
|
vector. @nicode{'} is simply a shorthand for a @code{quote} form.
|
||||||
|
@ -106,10 +105,9 @@ For example,
|
||||||
Note that an application must not attempt to modify literal lists or
|
Note that an application must not attempt to modify literal lists or
|
||||||
vectors obtained from a @code{quote} form, since they may be in
|
vectors obtained from a @code{quote} form, since they may be in
|
||||||
read-only memory.
|
read-only memory.
|
||||||
@end deffn
|
|
||||||
|
|
||||||
@deffn syntax quasiquote data
|
@item (quasiquote @var{data})
|
||||||
@deffnx syntax ` data
|
@itemx `@var{data}
|
||||||
Backquote quasi-quotation is like @code{quote}, but selected
|
Backquote quasi-quotation is like @code{quote}, but selected
|
||||||
sub-expressions are evaluated. This is a convenient way to construct
|
sub-expressions are evaluated. This is a convenient way to construct
|
||||||
a list or vector structure most of which is constant, but at certain
|
a list or vector structure most of which is constant, but at certain
|
||||||
|
@ -118,8 +116,10 @@ points should have expressions substituted.
|
||||||
The same effect can always be had with suitable @code{list},
|
The same effect can always be had with suitable @code{list},
|
||||||
@code{cons} or @code{vector} calls, but quasi-quoting is often easier.
|
@code{cons} or @code{vector} calls, but quasi-quoting is often easier.
|
||||||
|
|
||||||
@deffn syntax unquote expr
|
@table @nicode
|
||||||
@deffnx syntax , expr
|
|
||||||
|
@item (unquote @var{expr})
|
||||||
|
@itemx ,@var{expr}
|
||||||
Within the quasiquote @var{data}, @code{unquote} or @code{,} indicates
|
Within the quasiquote @var{data}, @code{unquote} or @code{,} indicates
|
||||||
an expression to be evaluated and inserted. The comma syntax @code{,}
|
an expression to be evaluated and inserted. The comma syntax @code{,}
|
||||||
is simply a shorthand for an @code{unquote} form. For example,
|
is simply a shorthand for an @code{unquote} form. For example,
|
||||||
|
@ -129,10 +129,9 @@ is simply a shorthand for an @code{unquote} form. For example,
|
||||||
`(1 (unquote (+ 1 1)) 3) @result{} (1 2 3)
|
`(1 (unquote (+ 1 1)) 3) @result{} (1 2 3)
|
||||||
`#(1 ,(/ 12 2)) @result{} #(1 6)
|
`#(1 ,(/ 12 2)) @result{} #(1 6)
|
||||||
@end example
|
@end example
|
||||||
@end deffn
|
|
||||||
|
|
||||||
@deffn syntax unquote-splicing expr
|
@item (unquote-splicing @var{expr})
|
||||||
@deffnx syntax ,@ expr
|
@itemx ,@@@var{expr}
|
||||||
Within the quasiquote @var{data}, @code{unquote-splicing} or
|
Within the quasiquote @var{data}, @code{unquote-splicing} or
|
||||||
@code{,@@} indicates an expression to be evaluated and the elements of
|
@code{,@@} indicates an expression to be evaluated and the elements of
|
||||||
the returned list inserted. @var{expr} must evaluate to a list. The
|
the returned list inserted. @var{expr} must evaluate to a list. The
|
||||||
|
@ -150,7 +149,8 @@ Notice @code{,@@} differs from plain @code{,} in the way one level of
|
||||||
nesting is stripped. For @code{,@@} the elements of a returned list
|
nesting is stripped. For @code{,@@} the elements of a returned list
|
||||||
are inserted, whereas with @code{,} it would be the list itself
|
are inserted, whereas with @code{,} it would be the list itself
|
||||||
inserted.
|
inserted.
|
||||||
@end deffn
|
@end table
|
||||||
|
|
||||||
@c
|
@c
|
||||||
@c FIXME: What can we say about the mutability of a quasiquote
|
@c FIXME: What can we say about the mutability of a quasiquote
|
||||||
@c result? R5RS doesn't seem to specify anything, though where it
|
@c result? R5RS doesn't seem to specify anything, though where it
|
||||||
|
@ -158,7 +158,8 @@ inserted.
|
||||||
@c presumably the "fixed" portions of a quasiquote expression must be
|
@c presumably the "fixed" portions of a quasiquote expression must be
|
||||||
@c treated as immutable.
|
@c treated as immutable.
|
||||||
@c
|
@c
|
||||||
@end deffn
|
|
||||||
|
@end table
|
||||||
|
|
||||||
|
|
||||||
@node Comments
|
@node Comments
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue