For Programmers: Free Programming Magazines  


Home > Archive > Prolog > March 2005 > Re: List cons functor (was Re: The meaning of module overriding syntax mod:goal in di









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: List cons functor (was Re: The meaning of module overriding syntax mod:goal in di
Zoltan Somogyi

2005-03-02, 3:58 am

Jens Kilian <jjk@acm.org> writes:
>A list *is* a compound term, to the user. As such, it needs to have
>a functor[1], and that functor may as well be '.'/2, IMHO. If I had to pick
>an alternate functor for consing lists, I'd at least use one that I could
>write without quotes. '[|]' is about the worst choice I can imagine -
>ugly, harder to type, easy to confuse with [1] or [l] or [I], and still needs
>quotes.


The question is: under what circumstances does the user have to type or
even see the cons function symbol?

In Mercury, we felt comfortable renaming the cons function symbol from "."
to "[|]" precisely because the answer to that question is: very rarely,
if at all. Application programs can always use X = [Y | Z] to build or
match lists, and generic program manipulation (metaprogramming) is done
using a ground representation (which allows the programmer to choose
how they wish to represent lists) instead of =.. and the like (which
impose the system's notion of the list constructor function symbol
on the user). Mercury does have mechanisms that work similarly to =..,
which are used only in a few places in system code, such as the
implementation of the Mercury debugger. As long as the debugger prettyprints
terms using [a, b, c, ...] syntax (which is not yet 100% in the Mercury
debugger, but getting there), the user need never know *what* the
cons function symbol is.

Zoltan Somogyi <zs@cs.mu.OZ.AU> http://www.cs.mu.oz.au/~zs/
Department of Computer Science and Software Engineering, Univ. of Melbourne
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com