[Haskell-cafe] Splitting Hairs Over Terminology

Dan Weston westondan at imageworks.com
Mon Feb 26 22:49:58 EST 2007

P. R. Stanley wrote:
> You know, as soon as I posted the message I remembered the destructive  
> assignment thingummy. the following is what I was talking about:
> Prelude> 13:[1, 2]
> [13, 1, 2]
> which I don't believe has an address in the memory, correct?

No. It does have a well-defined address in memory, which is there as 
long as you need it (and then garbage-collected away sometime thereafter).

> Back to the comma, surely, syntax sugar fulfills the role of an 
> operator, a function, or a sequence of low-level procedures, either in 
> part or comprehensively.

The ":" is actually a constructor, which is a function that is fully 
evaluated at compile time and on which you can do pattern matching. The 
list syntax also forms such a pattern.

> In C, for example, iteration could be implemented using the if construct 
> with the dreaded goto command. So, strictly speaking, the while loop 
> could be classed as syntax sugar. Yet, the while loop is a 
> well-recognized construct in its own right.
> I hope you can see what I'm driving at.

Syntactic sugar is fully desugared at compile time. A while loop with 
constant limits *could* be considered syntactic sugar if the compiler 
can statically unroll the loop. Variable limits are definitely beyond 
this definition, since they can only be evaluated at runtime.

Dan Weston

More information about the Haskell-Cafe mailing list