Alternative syntax for exporting things

Peter Schachte pets at students.cs.mu.oz.au
Fri Nov 28 11:39:34 AEDT 1997


This doesn't have anything to do with Tom's suggestion, except that he
reminded of an idea I had for a syntax extension.

I've never been terribly happy with the :- interface and :- implementation
sections of Mercury programs, as I'd rather write the pred/mode declarations
for public predicates as I do the private ones:  right before the
corresponding code.  I know Fergus has a document somewhere specifying an
alternative syntax for exporting things, but I find it a little bit too
verbose.

So here's a simple alternative proposal.  One could optionally put `public'
between the `:-' and the `pred', `mode', `inst', `type', etc in a
declaration to specify that it is public, despite not appearing in an
interface section. For example:

	:- public pred append(list(T), list(T), list(T)).


To allow abstract types, one could write something like

	:- abstract type blah --> ....

or maybe

	:- public abstract type blah --> ....


This could also be extended to allow things to be reexported (ie, imported
from one module that turns around and exports it) by just having the public
pred/type/whatever declaration for an imported thing, with no actual
definition in that module. 

That's it.  This has the virtue of being quite simple, concise, and regular,
and is still compatible with the current "section"-based approach.


-Peter Schachte			| Politicians are the same all over. They
pets at cs.mu.OZ.AU		| promise to build a bridge even where there is
http://www.cs.mu.oz.au/~pets/	| no river. -- Nikita Krushchev 
PGP key available on request	| 





More information about the developers mailing list