Do note that while the Haskell spec requires that the compiler
essentially read in every module into a single memory text blob and
*then* compile it, in practice Haskell implementations use separate
compilation.  What that sometimes means *in practice* is that if an
infix notation's precedence and associativity is defined in another
module, the Haskell implementation usually internally leaves an entire
sequence of infix as a single flat AST node, to be resolved at a later
stage in compilation when it already knows the actual precedence.

In Lisp terms, the following Haskell expression:

foo +++ bar *** nitz +++ meow

Gets converted to the following AST:

(nfx foo +++ bar *** nitz +++ meow)

And processing of the file continues.  At a later stage when imports
are figured out, *then* the Haskell compiler converts the AST to:

(+++ (+++ foo (*** bar nitz)) meow)

This is fine for Haskell in practice because Haskell acts as if it is
a compiled language where programs are loaded once, then executed.  In
a language like Lisp, programs and parts of programs are loaded
multiple times, possibly in various orders, and if the infix
notation's precedence changes, then we have a serious problem in how
we treat existing code using that infix notation.  In Haskell the
infix notation will get reinterpreted, since reloading the program
means reloading all the modules.  But in Lisp, how should we act if
only some submodule (and not the entire program) is reloaded, and the
newly loaded changes the precedence of some notation that another
submodule (which wasn't reloaded) uses.  Do we suddenly change its
AST?  Or not?

In addition, because macros get access to what is essentially the AST
of Lisp, this means that automatic infix detection will also require
that macros match on the (nfx ...) AST node.  In practice this is
rare, of course, since most macros will just rearrange expressions,
but macros may have a surprising interpretation of nfx nodes.

Sincerely,
AmkG

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Readable-discuss mailing list
Readable-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss

Reply via email to