FW: [mercury-users] Records

Peter Schachte schachte at cs.mu.OZ.AU
Tue Nov 9 22:35:47 AEDT 1999


On Tue, Nov 09, 1999 at 04:16:04PM +1300, Richard A. O'Keefe wrote:
> 	Infix `of' isn't bad, but I think there's something nice about having
> 	the function name come second.
> 
> Bet you love Postscript!

No, not really.  But I do like pipes in unix.  For functions with only
one argument, the postfix syntax works pretty intuitively.

> What I object to is yet another weird punctuation mark.

That's a fair point.  I think the default assumption should be that
new syntax should not be added to the language.  Only when it adds important
functionality or significant convenience that can't be added in a
library module should it be added.  The functionality we're discussing
cannot be added in a library module (I really wish at least the `^' and
`:=' features we're discussing could; alas, they have to be done by
source to source translation, and that's not currently very
convenient).

I do think automatic generation of accessor and setter functions is
sufficiently useful to add to the language.  Whether either or both of
the `^' and `:=' features are, I'm not sure.

> Come to think
> of it, isn't it high time we stopped living in the ASCII past?

Not yet.  Your email message was pretty unreadable to me.  Several
characters got messed up.  Personally, I'd love to write programs
using all the nifty mathematical symbols (La)TeX offers, but the world
is not ready yet.  I don't even think all the infrastructure is ready
for using ISO Latin 1 for language keywords.

> 	You can chain the :='s:
> 	
> 		R2 = R0 ^f := V1
> 		        ^g := V2
> 	
> Not in the presence of record invariants (Eiffel, I love you, sometimes).
> 
> 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.

I thought of that but decided it would get to complex to be workable.
E.g., if I instead wrote

		R2 = R0 ^g := V2
		        ^f := V1

it would look for a different function.  I don't want to have to
define setters for all permutations of accessors!  Ok, so you could
sort the accessor function names to make it canonical, but I still
don't want to have to define all the combinations of setters.  For
many types, many fields can be set independently; I only want to
define the individual ones.  Ok, so you could apply a rule that if the
combination setter is defined, you use it, if not, you use the
individual ones.  But what happens when you're setting 3 members, and
there are setters defined for each individual field and for each
combination of two?  The compiler could choose any of the 3 pairs
together with the remaining individual setter, and could apply these
two setters in either order, for 6 possible choices.  Which one do you
choose?


-- 
Peter Schachte                     In war, the first casualty is truth.
mailto:schachte at cs.mu.OZ.AU            -- Aeschylus, ca. 475 BC 
http://www.cs.mu.oz.au/~schachte/  
PGP: finger schachte at 128.250.37.3  
--------------------------------------------------------------------------
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