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

Peter Schachte schachte at cs.mu.OZ.AU
Tue Dec 5 16:36:11 AEDT 2000


On Tue, Dec 05, 2000 at 02:51:34PM +1100, Fergus Henderson wrote:
> 
> I do have one significant issue with this change, though: I don't
> particularly like the order in which the transformation puts the
> arguments.  In particular, IMHO would be more natural to make `A = A0
> ^ field(B, C) := D' compile to 'field :=' (A0, B, C, D, A) or perhaps
> 'field := '(B, C, D, A0, A), rather than to 'field :=' (B, C, A0, D, A)
> as (I think) is the case with the diff that you posted.

I thought 'field :=' was supposed to be a function, not a predicate.

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 Siman choose?

Anyway, if we pick policy (1), then W ^ f(X, Y) := Z could sensibly
translate to either (1a) 'f :='(W, X, Y, Z) or (1b) 'f :='(Z, W, X, Y).  For
policy (2), either (2a) 'f :='(Z, X, Y, W) or (2b) 'f :='(X, Y, W, Z) would
make sense.  (1a) has the virtue of keeping the variables in the order they
appear in the expression, which may be a bit easier to keep straight when
you're coding these functions.  (2b) is simple because ^ just applies the
closure on the right to the argument on the left, and := just transmogrifies
the function from f to 'f :=' and adds an extra argument on the end.  The
other two seem a bit odd to me.

> For example, I think it would be more natural to transform
> "Map = Map0 ^ elem(K) := V" to "'elem :=' (Map0, K, V, Map)",
> not "'elem :=' (K, Map0, V, Map)",

Shouldn't that be "Map = 'elem :='(K, Map0, V)", which would be policy
(1a)?  While the translation you don't like would be policy (2b).  It seems
to me the choice between these boils down to the choice between (1) and (2).

-- 
Peter Schachte <schachte at cs.mu.OZ.AU>  A baby is God's opinion that the
http://www.cs.mu.oz.au/~schachte/      world should go on.
Phone:  +61 3 8344 9166                    -- Carl Sandburg 
Fax:    +61 3 9348 1184                
--------------------------------------------------------------------------
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