Next: infix prec, Up: infix [Contents][Index]
Let’s consider that the library (mmck infix) exports the following extension functions and
syntaxes:
xor factorial != bitwise-arithmetic-shift-left bitwise-arithmetic-shift-right
Some expression syntax interpretation rules:
(infix list("ciao" , 'hello , '#u8(1 2 3 4)))
⇒ ("ciao" hello #u8(1 2 3 4))
(scheme), (chicken fixnum),
(chicken flonum) and (chicken bitwise) are interpreted as binary infix operators:
+ - * / expt quotient modulo remainder fx+ fx- fx* fx/ fxmod fxrem fp+ fp- fp* fp/ fpexpt < > <= >= = fx< fx> fx<= fx>= fx= fp< fp> fp<= fp>= fp= eq? eqv? equal? and or bitwise-and bitwise-ior bitwise-xor fxand fxior fxxor fxshl fxshr
the following bound identifiers exported by (mmck infix) are interpreted as binary infix
operators:
!= xor bitwise-arithmetic-shift-left bitwise-arithmetic-shift-right
in addition the following identifiers are recognised by their symbol name and interpreted as aliases of binary infix operators:
&& → and \x23D0;\x23D0; → or \x00AC; → not \x2227; → and \x2228; → or \x22BB; → xor == → = <> → != \x00D7; → * \x22C5; → * ** → expt % → mod & → bitwise-and \x23D0; → bitwise-ior ^ → bitwise-xor << → bitwise-arithmetic-shift-left >> → bitwise-arithmetic-shift-right
where the symbols with escape sequences are:
Unicode character not sign.
Unicode character times.
Unicode character logical and.
Unicode character logical or.
Unicode character xor.
Unicode character dot operator.
Unicode character vertical bar extension.
(scheme), (chicken fixnum) and
(chicken flonum) are interpreted as unary prefix operators:
+ - fx+ fx- fxneg fp+ fp- fpneg not bitwise-not fxnot
the following identifiers are recognised by their symbol name and are interpreted as unary prefix operators:
++ --
in addition the following identifiers are recognised by their symbol name and interpreted as aliases of unary prefix operators:
! → not ~ → bitwise-not
++ --
in addition the following identifiers are recognised by their symbol name and interpreted as aliases of unary postfix operators:
! → factorial
expt and
fpexpt which are right–associative:
;; left-associative (infix 10 - 5 - 3) → (- (- 10 5) 3) (infix 10 - 5 - 3) → (- 10 5 3) (infix 10 / 5 / 3) → (/ (/ 10 5) 3) (infix 10 / 5 / 3) → (/ 10 5 3) ;; right-associative (infix 10 expt 5 expt 3) → (expt 10 (expt 5 3)) (infix 10. fpexpt 5. fpexpt 3.) → (fpexpt 10. (fpexpt 5. 3.))
++ and -- are unary operators that can be applied to expressions
both in prefix and postfix positions. When applied in prefix position to an identifier,
++ expands to:
(infix ++ ?id) → (begin (set! ?id (+ ?id 1)) ?id)
and -- expands to:
(infix -- ?id) → (begin (set! ?id (- ?id 1)) ?id)
When applied in postfix position to an identifier, ++ expands to:
(infix ?id ++) → (let ((v ?id)) (set! ?id (+ ?id 1)) v)
and -- expands to:
(infix ?id --) → (let ((v ?id)) (set! ?id (- ?id 1)) v)
When applied to a non–identifier expression, both in prefix and postfix position, ++
expands to:
(infix ++ ?expr) → (+ ?expr 1) (infix ?expr ++) → (+ ?expr 1)
and -- expands to:
(infix -- ?expr) → (- ?expr 1) (infix ?expr --) → (- ?expr 1)
? and :, which are
recognised by their symbol name.
(infix 1 > 2 ? 3 + 4 : 5 * 6) → (if (> 1 2) (+ 3 4) (* 5 6))
(define (fun a b c) (+ a b c)) (infix fun (1 , 2 , 3)) → (fun 1 2 3) (infix fun(1, 2, 3)) → (fun 1 2 3)
NOTE The Scheme reader transforms the sequence:
, <form>into:
(unsyntax <form>)so the list of arguments is:
( <arg1> (unsyntax <arg>) ... )
quote and quasiquote are not subject to infix to prefix conversion;
the use of such syntaxes just expands to the prefix object:
(infix (quote ciao)) → (quote ciao) (infix (quasiquote ciao)) → (quasiquote ciao)
Next: infix prec, Up: infix [Contents][Index]
This document describes version 0.1.0-devel.0 of MMCK Infix.