Boost logo

Boost :

From: Kick Damien-DKICK1 (dkick1_at_[hidden])
Date: 2001-12-06 12:22:19


Andrei Alexandrescu [andrewalex_at_[hidden]] wrote:
> > Andrei Alexandrescu [andrewalex_at_[hidden]] wrote:
> > > From: "Geurt Vos" <G.Vos_at_[hidden]>
> > > > Can anyone explain why the members of the type list
> > > > template are called 'head' and 'tail'? I mean the
> > > > type list template is merely a node in a linked list
> > > > of types, where 'head' represents the content of the
> > > > node, and 'tail' points to the next node.
> > >
> > > Typelists are much like well-formed LISP-lists, in which "head"
> > > is an "atomic type" (non-typelist) and tail is actually another
> > > list, or nil. So "next" would not be a good choice. Besides,
> > > head and tail are quite consecrated for denoting this type of
> > > list.
> > >
> > > I don't think anyone would have liked 'car' and 'cdr' :o).
> >
> > How about 'first' and 'rest'?
>
> Why gratuitously invent new terminology when there's terminology in
> place that's well known.

'first' and 'rest' are not gratuitous, they are Common Lisp <grin>,
i.e. the less cryptic synonyms for 'car' and 'cdr'.

    (setq l '(a b c d e)) => (a b c d e)
    (first l) => a
    (rest l) => (b c d e)
    (last l) => (e)

If one wanted to use names that help relate typelists to "well-formed
LISP-lists" but did not want something as cryptic as 'car' and 'cdr',
it might be a viable option. You are saying that head is equivalent
to 'first', i.e. 'car', and that tail is equivalent to 'rest',
i.e. 'cdr'. At first glance, I would have thought that tail would be
closer in meaning to the CL concept of 'last' than it would be to the
CL concept of 'rest' because tail as a word can mean "something
resembling an animal's tail in [...] position" [<http://www.m-w.com>],
i.e. at the end. But I can also see how tail works as a synonym for
the CL concept of 'rest' because the word tail can mean "something
resembling an animal's tail in shape [...]: as a : the luminous train
of a comet" [ibid], which seems to be the meaning of the word that you
are using. So, <shrug>...

--
Damien Kick

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk