[mercury-users] Is DCG really appropriate, even for the things it does well?

Richard A. O'Keefe ok at cs.otago.ac.nz
Wed Apr 3 15:39:01 AEST 2002


	It would be nice to be able to use space as an operator,
		:- func list(T) list(T) = list(T).
		L1 L2 = list__append(L1, L2).
	
This has been tried in a couple of languages.  The one most readers are
likely to have met is AWK.  Some languages have used it for multiplication
(I think MadCap did this) and some for string concatenation.  It's
usually regarded as a really bad idea.  Amongst other things, unless you 
have an unusually smart IDE (not Alpha, Emacs, Brief,  BBEdit, &c) you
aren't going to be able to FIND uses of that operator very easily.

There's one thing I've often wanted in Prolog, and I actually wrote a
tokeniser to support it, and liked the result very much.  That is an
Algolish allowance of spaces in names, so that I could write

    p(Input List, Filtered List) :-
        input with keys(Input List, Keyed List),
        sort using keys(Keyed List, Sorted List),
        remove keys and duplicates(Sorted list, Filtered List).

Basically, <w><space>+<w'> turns into <w>_<w'>.  That's compatible with
"word" operators only if word operators are always quoted, and Haskell
programmers will find _that_ no hardship.  Add one more Algolish thing,
so that <w>(<args>) <w'>(<args'>) turns into
<w>_<w'>(<args>, <args'>) (really a generalisation of the previous idea)
and you can write

    input(Input List) with keys(Keyed List),

and things can look quite pretty to me, while looking just like

    input_with_keys(Input_List, Keyed_List)

to the Prolog compiler/interpreter.  Even as an old SNOBOL hacker,
I'd rather use space for this than for an operator.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list