[mercury-users] mercury website (was Suggestion: new operator )

Peter Schachte schachte at cs.mu.OZ.AU
Thu Oct 26 11:37:44 AEDT 2000


> They use "." for field access.  When you think about it, that's really
> an extremely odd choice.  The infix "OF" operator in COBOL and Algol 68
> makes a lot of sense, and "OF" was already a reserved word in Pascal.
> I suppose Pascal used it because PL/I used it, but does anyone know why
> PL/I used it?

This is just a WAG, but perhaps it's used like "." in sections and
subsections of a book:  3.2.5 means subsection 5 OF section 2 OF chapter 3.
What's nice about this, relative to using 'of' as an operator, is that you
write the outermost thing first, and the innermost thing last, which I find
more natural than the reverse.

I find it nicest to think of field access as function application (a field
name being just a unary function).  But having a special infix syntax for
function application that puts the function second makes field accesses more
readable.  Region^position^x reads better to me than x(position(Region)).
And conceiving of it as just a function allows users to use field access
syntax for things that aren't really fields (eg, radius and theta for a
rectangular coordinate).

Adding the ability to define how := works for each function gives Mercury
most or all of the capability of Common Lisp's SETF facility (in a
declarative way), but with a nicer syntax.  All in all, I can't think of
another language that has as clean a field access facility as Mercury.

-- 
Peter Schachte <schachte at cs.mu.OZ.AU>  The government of the United States
http://www.cs.mu.oz.au/~schachte/      is not, in any sense, founded on the
Phone:  +61 3 8344 9166                Christian religion.
Fax:    +61 3 9348 1184                    -- George Washington, 1796 
--------------------------------------------------------------------------
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