doc: added definition of trivial casts to spec
(cf @ignored Expr.Be and #1215 for intended use)
This commit is contained in:
parent
4ba3158e4f
commit
3ee2eb656e
1 changed files with 8 additions and 3 deletions
|
@ -2954,9 +2954,8 @@ analogous to a @code{become} expression in Newsqueak or Alef.} destroys the
|
||||||
current function activation frame and replaces it with an activation frame for
|
current function activation frame and replaces it with an activation frame for
|
||||||
the called function. In other words, @code{be} executes a tail-call. The
|
the called function. In other words, @code{be} executes a tail-call. The
|
||||||
syntactic form of a @code{be} expression is therefore limited to @emph{tail
|
syntactic form of a @code{be} expression is therefore limited to @emph{tail
|
||||||
position}: its argument must be a @emph{call expression}, and it must be the
|
position}: its argument must be a @emph{call expression} or a @{trivial cast}
|
||||||
last expression in a block.
|
of a @emph{call expression}, and it must be the last expression in a block.
|
||||||
|
|
||||||
An example of a @code{be} expression:
|
An example of a @code{be} expression:
|
||||||
@example
|
@example
|
||||||
fn print_loop(n: int) @{
|
fn print_loop(n: int) @{
|
||||||
|
@ -2971,6 +2970,7 @@ fn print_loop(n: int) @{
|
||||||
|
|
||||||
The above example executes in constant space, replacing each frame with a new
|
The above example executes in constant space, replacing each frame with a new
|
||||||
copy of itself.
|
copy of itself.
|
||||||
|
|
||||||
@end ignore
|
@end ignore
|
||||||
|
|
||||||
|
|
||||||
|
@ -3001,6 +3001,7 @@ execution and destroying the iterator frame.
|
||||||
@cindex As expression
|
@cindex As expression
|
||||||
@cindex Cast
|
@cindex Cast
|
||||||
@cindex Typecast
|
@cindex Typecast
|
||||||
|
@cindex Trivial cast
|
||||||
|
|
||||||
Executing an @code{as} expression casts the value on the left-hand side to the
|
Executing an @code{as} expression casts the value on the left-hand side to the
|
||||||
type on the right-hand side.
|
type on the right-hand side.
|
||||||
|
@ -3018,6 +3019,10 @@ fn avg(v: [float]) -> float @{
|
||||||
@}
|
@}
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
A cast is a @emph{trivial cast} iff the type of the casted expression and the
|
||||||
|
target type are identical after replacing all occurences of @code{int},
|
||||||
|
@code{uint}, @code{float} with their machine type equivalents of the
|
||||||
|
target architecture in both types.
|
||||||
|
|
||||||
@node Ref.Expr.Fail
|
@node Ref.Expr.Fail
|
||||||
@subsection Ref.Expr.Fail
|
@subsection Ref.Expr.Fail
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue