[m-dev.] syntax proposals

Ralph Becket rafe at cs.mu.OZ.AU
Wed Nov 7 12:27:41 AEDT 2001


Peter Schachte, Wednesday,  7 November 2001:
> On Wed, Nov 07, 2001 at 10:51:33AM +1100, Ralph Becket wrote:
> > 
> > 	:- 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.

Surely this is only an issue if we insist on using a Prolog style parser?

The tokenizer would only have to recognise `[|' as an end-of-term
marker.

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

True, but we do this anyway with `pragma type_spec' where the type
variable name is used to identify the arguments for specialization.

- 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