[m-dev.] syntax proposals

Peter Schachte schachte at cs.mu.OZ.AU
Wed Nov 7 12:17:12 AEDT 2001


On Wed, Nov 07, 2001 at 10:51:33AM +1100, Ralph Becket wrote:
> This stems from using lists to group nested declarations and
> definitions.  Can we introduce a different kind of `list' for this
> purpose which perserves the top-level syntax.  That is, rather than
> write
> 
> 	:- typeclass c(T) where [
> 		func f(T) = int,
> 		pred p(T),
> 		mode p(in) is semidet,
> 		...
> 	].
> 
> we would say
> 
> 	:- typeclass c(T) where [|
> 		:- func f(T) = int.
> 		:- pred p(T).
> 		:- mode p(in) is semidet.
> 		...
> 	|].

This is going to cause pain in the tokenizer/parser interaction, since the
tokenizer will see everything up to the first . as a term, and the parser
won't.  I think you'd need something other than . to end each item inside
the [| |] brackets.  Of course, you can't use , either because of the
precedence.

Another alternative might be something like:

	:- begin_typeclass c(T).
		:- func f(T) = int.
		:- pred p(T).
		:- mode p(in) is semidet.
	:- end_typeclass c(T).

Yes, I know that the variable name T appears in different items, and so
won't naturally be seen as the same variable.  But we can always say that it
does in this case.


-- 
Peter Schachte              Free trade is the weapon of the strong,
schachte at cs.mu.OZ.AU        protectionism is the shield of the weak.
www.cs.mu.oz.au/~schachte/      -- William Kaiser 
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