@emph{not} evaluated first. Instead it is up to the pmacro
to decide when, and if, the parameters are evaluated.
The syntactic forms are: @code{.pmacro}, @code{.let}, @code{.if},
-@code{.case}, @code{.cond}, @code{.begin}, @code{.and}, and @code{.or}.
+@code{.case}, @code{.cond}, @code{.begin}, @code{.andif}, and @code{.orif}.
If the result of the pmacro is another pmacro invocation,
it is in turn processed.
@menu
* .equals:: Deep comparison
-* .and:: && in C
-* .or:: || in C
+* .andif:: && in C
+* .orif:: || in C
* .not:: ! in C
* .eq:: Shallow comparison
* .ne:: Shallow comparison
(.equals ((1 2 3) (4 5 6)) ((1 2 3) (4 5 6))) --> #t
@end smallexample
-@node .and
-@subsection .and
-@cindex .and
+@node .andif
+@subsection .andif
+@cindex .andif
-Syntax: @samp{(.and [expr1 [expr2 ...]])}
+Syntax: @samp{(.andif [expr1 [expr2 ...]])}
Each expression is evaluated in turn.
If an expression evaluates to false (@code{#f}) then
Examples:
@smallexample
-(.and 1 #f 2) --> #f
-(.and 1 2 3) --> 3
-(.and) --> #t
+(.andif 1 #f 2) --> #f
+(.andif 1 2 3) --> 3
+(.andif) --> #t
@end smallexample
-@node .or
-@subsection .or
-@cindex .or
+@node .orif
+@subsection .orif
+@cindex .orif
-Syntax: @samp{(.or [expr1 [expr2 ...]])}
+Syntax: @samp{(.orif [expr1 [expr2 ...]])}
Each expression is evaluated in turn.
If an expression evaluates to non-false (@code{#f}) then
Examples:
@smallexample
-(.or 1 2 3) --> 1
-(.or #f #f #f) --> #f
-(.or) --> #f
+(.orif 1 2 3) --> 1
+(.orif #f #f #f) --> #f
+(.orif) --> #f
@end smallexample
@node .not
If @code{expr} is @code{#f} return @code{#t}.
If @code{expr} is non-@code{#f} return @code{#f}.
+@emph{Note that (.not 0) is not 1, it is #f!}.
+
@node .eq
@subsection .eq
@cindex .eq
* .sll:: Shift left logical
* .srl:: Shift right logical
* .sra:: Shift right arithmetic
-* .bitand:: Bitwise and
-* .bitor:: Bitwise or
-* .bitxor:: Bitwise exclusive-or
-* .bitinv:: Bitwise inversion
+* .and:: Bitwise and
+* .or:: Bitwise or
+* .xor:: Bitwise exclusive-or
+* .inv:: Bitwise inversion
@end menu
@node .sll
@code{n} must be a non-negative integer.
-@node .bitand
-@subsection .bitand
-@cindex .bitand
+@node .and
+@subsection .and
+@cindex .and
-Syntax: @samp{(.bitand x y)}
+Syntax: @samp{(.and x y)}
Return the bitwise @code{and} of @code{x} and @code{y}.
-@node .bitor
-@subsection .bitor
-@cindex .bitor
+@node .or
+@subsection .or
+@cindex .or
-Syntax: @samp{(.bitor x y)}
+Syntax: @samp{(.or x y)}
Return the bitwise @code{or} of @code{x} and @code{y}.
-@node .bitxor
-@subsection .bitxor
-@cindex .bitxor
+@node .xor
+@subsection .xor
+@cindex .xor
-Syntax: @samp{(.bitxor x y)}
+Syntax: @samp{(.xor x y)}
Return the bitwise @code{exclusive-or} of @code{x} and @code{y}.
-@node .bitinv
-@subsection .bitinv
-@cindex .bitinv
+@node .inv
+@subsection .inv
+@cindex .inv
-Syntax: @samp{(.bitinv x)}
+Syntax: @samp{(.inv x)}
Return the bitwise @code{inversion} of @code{x}.
; (.length x) - length of symbol, string, or list
; (.replicate n expr) - return list of expr replicated n times
; (.equals x y) - deep comparison
-; (.and expr . rest) - && in C
-; (.or expr . rest) - || in C
+; (.andif expr . rest) - && in C
+; (.orif expr . rest) - || in C
; (.not expr) - ! in C
; (.eq x y)
; (.ne x y)
; (.sll x n) - shift left logical
; (.srl x n) - shift right logical
; (.sra x n) - shift right arithmetic
-; (.bitand x y) - bitwise and
-; (.bitor x y) - bitwise or
-; (.bitxor x y) - bitwise xor
-; (.bitinv x) - bitwise invert
+; (.and x y) - bitwise and
+; (.or x y) - bitwise or
+; (.xor x y) - bitwise xor
+; (.inv x) - bitwise invert
; (.car l)
; (.cdr l)
; (.caar l)
(equal? x y)
)
-; (.and . rest)
+; (.andif . rest)
; Note: syntactic form
; Elements of EXPRS are evaluated one at a time.
; Unprocessed elements are not evaluated.
-(define (-pmacro-builtin-and env . exprs)
+(define (-pmacro-builtin-andif env . exprs)
(if (null? exprs)
#t
(let loop ((exprs exprs))
(else #f)))))
)
-; (.or . rest)
+; (.orif . rest)
; Note: syntactic form
; Elements of EXPRS are evaluated one at a time.
; Unprocessed elements are not evaluated.
-(define (-pmacro-builtin-or env . exprs)
+(define (-pmacro-builtin-orif env . exprs)
(let loop ((exprs exprs))
(if (null? exprs)
#f
(else (quotient x (* n 2))))
)
-; (.bitand x y) - bitwise and
+; (.and x y) - bitwise and
-(define (-pmacro-builtin-bitand x y)
- (-pmacro-verify-integer ".bitand" x)
- (-pmacro-verify-integer ".bitand" y)
+(define (-pmacro-builtin-and x y)
+ (-pmacro-verify-integer ".and" x)
+ (-pmacro-verify-integer ".and" y)
(logand x y)
)
-; (.bitor x y) - bitwise or
+; (.or x y) - bitwise or
-(define (-pmacro-builtin-bitor x y)
- (-pmacro-verify-integer ".bitor" x)
- (-pmacro-verify-integer ".bitor" y)
+(define (-pmacro-builtin-or x y)
+ (-pmacro-verify-integer ".or" x)
+ (-pmacro-verify-integer ".or" y)
(logior x y)
)
-; (.bitxor x y) - bitwise xor
+; (.xor x y) - bitwise xor
-(define (-pmacro-builtin-bitxor x y)
- (-pmacro-verify-integer ".bitxor" x)
- (-pmacro-verify-integer ".bitxor" y)
+(define (-pmacro-builtin-xor x y)
+ (-pmacro-verify-integer ".xor" x)
+ (-pmacro-verify-integer ".xor" y)
(logxor x y)
)
-; (.bitinv x) - bitwise invert
+; (.inv x) - bitwise invert
-(define (-pmacro-builtin-bitinv x)
- (-pmacro-verify-integer ".bitinv" x)
+(define (-pmacro-builtin-inv x)
+ (-pmacro-verify-integer ".inv" x)
(lognot x)
)
(list '.length '(x) #f -pmacro-builtin-length "return length of symbol, string, or list")
(list '.replicate '(n expr) #f -pmacro-builtin-replicate "return list of expr replicated n times")
(list '.equals '(x y) #f -pmacro-builtin-equals "deep comparison of x and y")
- (list '.and 'rest #t -pmacro-builtin-and "return #f if any element is #f, otherwise return last element")
- (list '.or 'rest #t -pmacro-builtin-or "return first non-#f element, otherwise #f")
+ (list '.andif 'rest #t -pmacro-builtin-andif "return first #f element, otherwise return last element")
+ (list '.orif 'rest #t -pmacro-builtin-orif "return first non-#f element found, otherwise #f")
(list '.not '(x) #f -pmacro-builtin-not "return !x")
(list '.eq '(x y) #f -pmacro-builtin-eq "return true if x == y")
(list '.ne '(x y) #f -pmacro-builtin-ne "return true if x != y")
(list '.sll '(x n) #f -pmacro-builtin-sll "return logical x << n")
(list '.srl '(x n) #f -pmacro-builtin-srl "return logical x >> n")
(list '.sra '(x n) #f -pmacro-builtin-sra "return arithmetic x >> n")
- (list '.bitand '(x y) #f -pmacro-builtin-bitand "return x & y")
- (list '.bitor '(x y) #f -pmacro-builtin-bitor "return x | y")
- (list '.bitxor '(x y) #f -pmacro-builtin-bitxor "return x ^ y")
- (list '.bitinv '(x) #f -pmacro-builtin-bitinv "return ~x")
+ (list '.and '(x y) #f -pmacro-builtin-and "return x & y")
+ (list '.or '(x y) #f -pmacro-builtin-or "return x | y")
+ (list '.xor '(x y) #f -pmacro-builtin-xor "return x ^ y")
+ (list '.inv '(x) #f -pmacro-builtin-inv "return ~x")
(list '.car '(x) #f -pmacro-builtin-car "return (car x)")
(list '.cdr '(x) #f -pmacro-builtin-cdr "return (cdr x)")
(list '.caar '(x) #f -pmacro-builtin-caar "return (caar x)")