FW: [mercury-users] Records

Richard A. O'Keefe ok at hermes.otago.ac.nz
Tue Nov 9 14:16:04 AEDT 1999


	Infix `of' isn't bad, but I think there's something nice about having
	the function name come second.

Bet you love Postscript!

I note that Pop-2 has, for about three decades, ruled that x.f and f(x)
are the same thing.  That has always seemed quite sensible to me.  Pop
also handles updates in a Common-Lispish way (or rather, Common Lisp
belatedly handled updates in a rather Poppish way):  expr -> f(x)
is basically the same as updaterof(f)(expr, f).  Arrays in Pop were/are
syntactically functions, so if you want to write i.a, j.a -> i.a, j.a
to swap elements i and j of arrays, that was fine too.

I further note that Dijkstra and his followers seem to have moved to a
suffix notation for function calls too, although I haven't quite figured
out just how x.y.f manages to mean f(x,y).

Peter Schachte, Lee Naish, and I are in complete agreement that record
fields _are_ functions so might as well _look_ and _act_ like functions.

What I object to is yet another weird punctuation mark.  Come to think
of it, isn't it high time we stopped living in the ASCII past?  Even
ISO Latin 1 is creaking at the joints, and Unicode is no longer a pup.

Why not use the ISO Latin 1 "section" sign (U+00A7) as field operator,
so that
    X § f = f(X)
and use the left/right guillemets (no, Adobe, NOT guillemots, those are
birds and these are quotation marks, they're different if you look closely)
as brackets for updates?

    X « f := New_F, g := New_G »

These characters are the in MacRoman character set (section is Option-6,
left/right guillemet are Option-\ and Option-|), in the Windows
character sets, and most of the ISO 8859 family members, so they are
nearly as portable as ASCII.

	You can chain the :='s:
	
		R2 = R0 ^f := V1
		        ^g := V2
	
Not in the presence of record invariants (Eiffel, I love you, sometimes).
Peter Schachte's suggest that we switch off constraint checking in terms
"used as nothing other than an input to a function whose name ends with
:=" won't work, because then *no* field update function would be able to
assume the record invariant as true.

What one _can_ do is form compound names, so that
my example above with the guillemets is mapped to
    'f:=g:='(X, New_F, New_G)
In general, there need not be any 'f:=' and 'g:=' functions that it is
composed from.
--------------------------------------------------------------------------
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