[mercury-users] Custom declarations and preprocessors.
Manuel Hermenegildo
herme at clip.dia.fi.upm.es
Fri Apr 14 19:32:03 AEST 2000
Peter makes some valid points: there are indeed advantages to literate
programming using comments but there are also advantages to such
comments being declarations. I personally prefer declarations (and in
the lpdoc tool that is what we have so far) for the reasons eloquently
pointed out by Tyson and also because we view declarations,
assertions, and comments not as separate things but rather as
different points of a continuum (something that may or may not be the
appropriate view in the context of Mercury). In fact, in lpdoc we even
mix comments and the actual type/mode declarations all the time:
:- pred double(+X,-Y) :: int * int # "@var{Y} is twice @var{X}".
This has the advantage that it is almost literally what a programmer
would typically write in a comment and at the same time an assertion
giving a mode and types to the compiler. Also, consider:
:- regtype filename(X) # "@var{X} is the name of a file.".
filename := atom.
and then
:- pred read(+filename).
lpdoc automatically puts in the documentation for read/1 that the
argument is input and that it should be a file name (in words).
But, again, using comments or declarations is really a matter of
taste. In fact, in lpdoc the plan is to support both, possibly using
special syntax (e.g., starting with %!) for the machine-readable
comments (this was inspired by a proposal some time ago made by the
Siemens Prolog people), although we have not found the time yet to add
the option of reading comments to the reader.
Manuel
--
-----------------------------------------------------------------------------
herme at fi.upm.es | Manuel Hermenegildo
+34-91-336-7435 (Work) | Facultad de Informatica, UPM
+34-91-352-4819 or 336-7412 (FAX) | Universidad Politecnica de Madrid
http://www.clip.dia.fi.upm.es/~herme | 28660-Boadilla del Monte, MADRID SPAIN
-----------------------------------------------------------------------------
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list