[m-dev.] io__write et al

Fergus Henderson fjh at cs.mu.oz.au
Wed Apr 23 15:06:01 AEST 1997


Peter Schachte, you wrote:
> 
> > > Shouldn't we start encouraging the notation `io:print'?
> > 
> > No.  That notation should be DIScouraged, because it is going to change
> > to `io.print'.  But of course we shouldn't start encouraging the notation
> > `io.print' until after we have implemented it...
> 
> This doesn't seem like a good idea.
...
> What's the rationale for making this change?

The rationale is that this seems to be the best way of coming up with a simple,
consistent syntax for type qualification, module qualification, and records.

					Operator	Examples

	Module qualification:		.		module.name

	Type qualification:		:		expr : type

							:- type foo ---> foo(
							   field_name1 : type1,
							   field_name2 : type2
							).

	Mode qualification:		::		:- pred p(type::mode).

I still haven't quite figured out what I think the best syntax is for all the
record operations, though.

> Firstly, it is error prone, as some
> people will tend to write io . print(...).

It may be a little confusing initially for some people, but I don't think
it will be error prone.  I think people will just get into the habit of
writing `io.print'.  I don't think this is the sort of mistake that any
given person would be likely to make often.
(Now comma as separator is error-prone...)

Anyway, if we are going to use dot as an operator despite this problem,
then module qualification is a good choice.

> Thirdly, does this mean that we can't use '.' as this list constructor
> anymore? Shouldn't io.print() be the list [io|print()]? 

You can't use infix '.' as the list constructor, but that is not a change;
that is enshrined in ISO Prolog, and has always been the case in Mercury.
If you want to use '.' as the list constructor, you have to write it prefix.

> Secondly, the infix dot
> notation is more orthodoxly used for structure member reference,

True, but many languages use it for both structure members and module
members.

> Finally, colon is a much more conventional module qualification operator. 

Prolog is the only language I know that uses ":" as a module qualification
operator.

Language	Modules			Types			Structs
--------        -------                 -----                   -------
Haskell		module.member		expr::type		field record
Ada		package.member		var:type		record.field
Java		package.member		         		class.member
SML		structure.member	expr:type		record.field
Prolog		module:member
C++		namespace::member	         		class.member or
   		                 				class::member
Perl		package::member

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list