On Sat, Jan 19, 2008 at 01:29:02PM -0500, Jonathan S. Shapiro wrote: > 3. Built-in Operators > > In the s-block syntax, BitC will parse infix and prefix arithmetic, > boolean, and bit operators with the customary precedence rules. Since > these symbols are actually type class methods, we have two choices: > > 1. Admit these symbols as identifiers in general. > > 2. Define these symbols to have canonical rewritings to legal > identifiers, and do not alter the legal identifier name space. > > I mildly prefer the second approach. Any objections?
Haskell has a nice feature where any sequence of punctuation characters is treated as an infix operator. Normal functions can be used inline by surrounding them in backticks, improving readability in some cases. E.g. (.+.) i j = (if i < 0 then 0 else i) + j 2 .+. 2 ==> 4 (-2) .+. 2 ==> 2 operator precedence and associativity can be specified by doing something like: infixr 5 .+. -2 .+. 2 ==> 2 an example of using a normal function infix is: lst `contains` elem The custom operator stuff is great because it means the standard library isn't special and can be more readily extended. The backtick trick only works on identifiers (parsing is tricky otherwise) but can be useful, only the parser should be affected in any meaningful way in the implementation. The dynamic specification of infix associativity is probably pretty tricky to implement, though it does improve expressiveness. Sam _______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
