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

Peter Schachte schachte at cs.mu.OZ.AU
Wed Jan 30 17:38:02 AEDT 2002


On Tue, Jan 29, 2002 at 05:41:13PM +1100, Ralph Becket wrote:
> If you have an opinion, please let me know which of these alternatives
> for the state variable syntax you prefer ASAP:
> 
> (1 - the status quo)
> 	!+X refers to the "current" notional value of state variable X,
> 	!-X refers to the "next" notional value of state variable X.
> 
> 	Inspiration: Prolog convention for labelling argument modes.
> 
> (2 - Fergus' suggestion, in receipt of broad support)
> 	!=X refers to the "current" notional value of state variable X,
> 	!+X refers to the "next" notional value of state variable X.
> 
> 	Intuition: the `=' is indicative of keeping the state variable
> 	"number" the same (if one were to use variable numbering
> 	instead); the `+' is indicative of incrementing the state
> 	variable "number".
> 
> (3)
> 	!<X refers to the "current" notional value of state variable X,
> 	!>X refers to the "next" notional value of state variable X.
> 
> 	Intuition: `<' is reminiscent of Unix shell "read" redirection;
> 	           `>' is reminiscent of Unix shell "write" redirection.

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.

Using scheme 2, initializing a thread X would look like:

		!=X = 0

which I think looks bad no matter how you lay it out.
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

Scheme3 is pretty ugly too (looks too much like a bizzare
XML/HTML/SGML tag):

		!<X = X>X + 1

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

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

Increment:

	!:X = !X + 1

These look better than any of 1, 2, or 3 to me.

-- 
Peter Schachte              I disapprove of what you say, but I will defend
schachte at cs.mu.OZ.AU        to the death your right to say it.
www.cs.mu.oz.au/~schachte/      -- Voltaire 
Phone: +61 3 8344 9166      
--------------------------------------------------------------------------
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