[Haskell-cafe] Splitting Hairs Over Terminology
Brandon S. Allbery KF8NH
allbery at ece.cmu.edu
Mon Feb 26 21:36:36 EST 2007
On Feb 26, 2007, at 21:27 , P. R. Stanley wrote:
> Hi folks
> in C and C++ world the humble comma is an operator. Is this also
> the case in Haskell or, is it classed as a function?
Neither; it's syntactic sugar. The formal tuple constructor is (,
[,...]) a [b ...] (e.g. (,,) a b c), with (a, b, c) a friendlier
syntax for it, just as [a, b, c] is syntactic sugar for a : b : c : .
> In the wikibook they talk about consing new elements onto a list.
> Does this cons stand for anything meaningful in the English
> language? For example, is it short for construction or something
It's "construct", but the term was actually borrowed from Lisp.
Count yourself lucky Haskell doesn't use the related Lisp terms "car"
and "cdr", which are named after registers in some ancient IBM CPU
architecture. Haskell went with the saner "head" and "tail" instead.
> I'm assuming that the ":" function takes two arguments and returns
> a newly constructed list which is assigned to the variable holding/
> pointing to the old list.
First part correct, second quite wrong --- Haskell doesn't have
destructive assignment in the general case. There are special cases,
such as IORefs and MVars and TVars, but Haskell puts restrictions on
how you go about using such impure operations.
brandon s. allbery [linux,solaris,freebsd,perl] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university KF8NH
More information about the Haskell-Cafe