[m-dev.] for review: improvements for record syntax

schachte at cs.mu.OZ.AU schachte at cs.mu.OZ.AU
Wed Dec 6 10:42:12 AEDT 2000


On  6 Dec, Simon Taylor wrote:
> Fergus wrote:
>> On 05-Dec-2000, Peter Schachte <schachte at cs.mu.OZ.AU> wrote:
>> > I see two sensible ways to handle `^'.  Given the term W ^ f(X, Y), it could
>> > traslate into either (1) f(W, X, Y) or (2) f(X, Y, W).  Ralph, I believe,
>> > preferred the former; I don't really have a preference.  I didn't look that
>> > closely at the diff, which approach did Simon choose?
>> 
>> Simon chose (2).
>> I'm with Ralph in preferring (1).
> 
> I think it's worth keeping the equivalence between field selection
> and function application. The only reason they're not completely
> equivalent now is that the compiler doesn't do mode inference for
> higher-order terms.

That's true, but the `:=' form can't be looked at that way, so I'm not
sure it's terribly important to be consistent with function application
in this case.

I think the best way to decide issues like this is to first make it as
simple as possible for users, then make it as simple as possible for
developers, and finally make it as simple as possible for
compiler-writers. The policy choice here doesn't matter to users, so we
should make it as simple and natural as possible for people defining
accessors and setters.  So the question is:  is it more natural to
write functions to, say, index and update an array as

	:- func elem(array, index) = int.
	:- func 'elem :='(array, index, int) = array.

or

	:- func elem(index, array) = int.
	:- func 'elem :='(index, array, int) = array.

I guess the former look a bit better to me, so that puts me with Ralph
and Fergus in preferring what I was calling policy (1a), but it's a
fairly weak preference.

-- 
Peter Schachte                     The use of COBOL cripples the mind; its
mailto:schachte at cs.mu.OZ.AU        teaching should, therefore, be regarded
http://www.cs.mu.oz.au/~schachte/  as a criminal offense.
PGP: finger schachte at 128.250.37.3      -- E. W. Dijkstra 

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list