[m-dev.] Alternative syntax for exporting things
Fergus Henderson
fjh at cs.mu.oz.au
Fri Nov 28 18:31:13 AEDT 1997
Peter Schachte wrote:
>
> 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.
The trouble with this is that it becomes difficult to separate the
module interface from the implementation. So I would oppose any
such change, at least unless/until the proposal is accompanied
by a tool for extracting a human-readable versionof the module interface,
including comments.
> I know Fergus has a document somewhere specifying an
> alternative syntax for exporting things, but I find it a little bit too
> verbose.
"somwhere" = compiler/notes/module_system.html.
> 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 --> ....
How about the following alternative?
:- public type blah.
:- 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.
Ugh. I don't think that suggestion would work well.
(For example, what if you have to module-qualify the thing you
are re-exporting?)
I would much prefer a separate keyword for that.
> That's it. This has the virtue of being quite simple, concise, and regular,
Agreed.
> and is still compatible with the current "section"-based approach.
You lost me there.
It seems quite different to the current section-based approach.
--
Fergus Henderson <fjh at cs.mu.oz.au> WWW: <http://www.cs.mu.oz.au/~fjh>
Note: due to some buggy software and a (probably accidental)
denial-of-service attack, any mail sent to me between
Tue Nov 25 20:00:00 UTC (6am Wed, local time)
and Wed Nov 26 06:00:00 UTC (4pm, local time)
may have gone into the bit-bucket. Please re-send it.
More information about the developers
mailing list