[m-dev.] proposed syntax for typed insts

Julien Fischer jfischer at opturion.com
Tue Sep 8 15:01:36 AEST 2015


Hi,

On Mon, 7 Sep 2015, Zoltan Somogyi wrote:

> I am proposing a syntax for typed insts, which we have
> long agreed are a good idea.
>
> Currently, inst declarations look like either this:
>
> :- inst Instname(InstArgs) == ...
>
> or like this:
>
> :- inst InstName(InstArgs) ---> ...
>
> I propose that "for TypeName/TypeArity" be added
> between the InstName(InstArgs) and the "==" or "---->",
> so that they look like this:
>
> :- inst InstName(InstArgs) for TypeName/TypeArity == ...
>
> This can be achieved by adding "for" as a new xfx operator
> with a priority that is lower than the priority of either --->,
> which is 1179, and of "==", which is 700. (In a perversity
> inherited from Prolog, lower priorities bind more *tightly*.)
> That way, the part of the term that we read in for an inst
> definition with have InstName(InstArgs) for TypeName/TypeArity
> in the slot that used to have just InstName(InstArgs)
> (the slot being the left argument term of ---> or ==),  and
> everything else will remain the same as far as parsing
> the inst definition is concerned. ("inst" is prefix op with
> priority 1199, so it binds loosest of all these operators.)

I have no objection to adding "for" as the new operator.

> I am attaching a program that reads in terms and prints them
> showing the priorities of the relevant ops, two inst definitions
> from tree234.m (one with ---> and one with ==), both in their
> current untyped form and in the proposed typed form, and the
> output of the program on these inst definitions as terms after
> "for" is added as an xfx op with priority 500.
>
> What do people think about the proposal? Should the keyword
> be something other than "for"? Should we require typed insts
> to use :- typed_inst instead of just :- inst? Should the syntax
> structure be completely different?

At this stage I would say no, but it depends a bit on the
details of how typed insts are going to fit into the language.
(For example, in their presence will we eventually restrict what
untyped insts are allowed?)

> As an aside, is show_ops.m worth adding to extras?

Sure.

Julien.



More information about the developers mailing list