[m-dev.] State variable syntax - last call for opinions

Ralph Becket rafe at cs.mu.OZ.AU
Wed Jan 30 17:57:15 AEDT 2002


Peter Schachte, Wednesday, 30 January 2002:
> 
> Hmmm.  I was going to say I prefer option 2, 3 would be OK, and I find
> 1 confusing.  Then I tried to write a small bit of code to do a little
> arithmetic threading using this scheme and was aghast at what it
> looked like.

Option 1 is definitely out: like the Prolog convention that inspired it,
it's not at all obvious which is which.

> Using scheme 2, initializing a thread X would look like:
> 
> 		!=X = 0

No, to initialize state variable X you'd write

		!+X = 0

> which I think looks bad no matter how you lay it out.

I think scheme 2 is pig ugly, but it did receive the most support.  I'm
only requesting a recount because I'm having trouble stomaching scheme 2
(although I am reluctant to fly in the face of public opinion :)

> Scheme 3 is a bit better:
> 
> 		!>X = 0
> 
> and scheme 1 looks OK (though it looks to me like you're incrementing
> rather than binding the variable).
> 
> 		!+X = 0
> 
> Incrementing a thread X in scheme 2 is also pretty bad:
> 
> 		!+X = !=X + 1

Hooargh.

> Scheme3 is pretty ugly too (looks too much like a bizzare
> XML/HTML/SGML tag):
> 
> 		!<X = !>X + 1

That's not quite right.  I think you mean

		!>X = !<X + 1

I could transpose !< to <!

		!>X = <!X + 1

(I rather like this one) or even make it a postfix operator

		!>X = X<! + 1

Any takers?

> Scheme 1 isn't much better:
> 
> 		!-X = !+X + 1
> 
> So how about a 4th proposal:
> 
> 	!X means the current value of thread X
> 	!:X means the next value of thread X
> 	!!X means !X, !:X in an atom

Personally I don't find this any more attractive than the other options
(3 would be my choice.)  The drawback is that !!X is going to be the
common case while !X and !:X will be used only occasionally.

> Rationale (thin, I admit):  ! looks a little like a piece of thread.
> The colon could look a bit like a piece of thread cut in half (or
> think of the : in := signifying assignment).  And !! is two threads.
> 
> Initialization:
> 
> 	!X = 0

That would have to be

	!:X = 0
> 
> Increment:
> 
> 	!:X = !X + 1
> 
> These look better than any of 1, 2, or 3 to me.

Much as it pains me (democracy being the worst of all possible systems,
apart from the others), unless there is more support for anything other
than scheme 2, I'm going to have to go with that one...

- Ralph
--------------------------------------------------------------------------
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