[bitc-dev] Current thoughts on mixfix
wren ng thornton
wren at freegeek.org
Fri Sep 3 21:29:00 PDT 2010
On 9/2/10 2:23 PM, Jonathan S. Shapiro wrote:
> But this has a consequence: the introduction of syntax has to be a binding
> construct, because different operators may end up binding the same function
> in different syntaxes. So we need to use something like:
>
> mixfix *precedence* _+_ = add*;*
>
> where "add" is a function of two arguments.
N.B. this is part of the caml4p antipattern. Introducing a separation
between "the function" and "the syntax" (within the language itself, as
opposed to within the compiler/denotation) leads to a lot of confusion
and makes it very easy to break things.
I think it's far better to take the Haskell approach of every function
having a primary syntax (e.g., prefix for alphabetic, infix for
symbolic) and then having linguistic rules for converting that primary
syntax to another syntax as necessary (e.g., sections of infix
functions, the backtick notation). In particular, it's fine to define
the *function* _+_ by saying it's equal to add (and then
specifying/relying on inlining to remove the indirection); but having
_+_ belong to a separate ontological category from add is just begging
for problems.
--
Live well,
~wren
More information about the bitc-dev
mailing list