[mercury-users] constructor class syntax

Richard A. O'Keefe ok at hermes.otago.ac.nz
Fri Nov 5 08:03:32 AEDT 1999


Samuel Sean Watkins <108703 at bud.cc.swin.edu.au> wrote:

	Okay, okay, what I *meant* was, contextual grammar is a nice idea, as 
	opposed to context-free grammar.

It's not clear what "contextual grammar" means.
I don't know of any useful programming languages that have context-free
grammars.  Like Pascal, they have context-free *covering* grammars, with
*constraints* that require used things to have been declared, to have
appropriate types, and so on.  In that sense, Mercury _has_ a context-
sensitive grammar.  (In fact, given the complexity of Mercury type and
mode checking, it requires a Type 0 grammar.)

More interesting is the case where a given form has a different meaning
depending on where it is in the program.  Even then, consider a[4].  In
C, that form can be used to _declare_ that `a' is an array containing
exactly 4 elements, or to _access_ the 5th element of an array having
more than 4 elements.  And of course, unlike Algol and Pascal, C's `/'
operator is notoriously context-sensitive.

I've used languages with context-sensitive features (e.g. in PL/I, `IF'
might or might not be a reserved word, depending on where you use it).
and there were no advantages over   I didn't particularly enjoy the
experience.

	Perl's treatment of plurals is 
	interesting (a list without walls, if you like).  Larry Wall is a 
	linguist, and some of the features of Perl reflect his linguistic insight.

Which?  I know a fair bit about linguistics myself.
Perl has no interesting morphology.
Perl makes no use to features like gender (in the grammatical sense;
many languages have four or more genders).
If there's some kind of consistent X-bar syntax underlying Perl,
I've never been able to see it.
Above all, natural languages can be *read aloud*.
Perl is just what Larry Wall said it was, an *eclectic* mix of an
assortment of older programming languages.

	By the way, Perl has records indexed by name (hashes).
	Dare I suggest Mercury should adopt '$record{field}' ?
	
That's a rather unusual perspective:  they are more usually seen
as "dictionaries" or "tables" rather than "records".  Mercury already
_has_ dictionaries.  For field access, the "abstract pattern" stuff
I presented at the Erlang conference last year would adapt to Mercury
very nicely, and would actually be in the spirit of Mercury.
--------------------------------------------------------------------------
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