[mercury-users] About functional notation and IO

Gustavo A. Ospina gos at info.fundp.ac.be
Fri Jun 18 18:21:49 AEST 1999


>Mercury already has something like that: `impure'.  See the "Impurity"
>section of the "Pragmas" chapter of the Mercury language reference manual.
>
>You could implement an I/O library using `impure' rather than
>using `io__state', if you wanted.

That was not my intention. At least in my Mercury programs, I must respect
the purity and declarative semantics.

>Using `impure', it would look like this:
>
>	:- impure pred hi is det.
>	hi :-
>		impure io__write("Hi").
>
>Note that the call is annotated with `impure', not just the pred declaration.
>If you omit the `impure' annotation on the call, then you get a compile
error.

I'm in agree with anotate the calls to the predicates using IO or
explicitly with side effects.

It seems a well alternative, which can be justified by the same declarative
semantics for IO predicates. I would think in other operator (not reserved
word :) to specific IO calls, in order to not confuse with other uses of
impurity predicates, but if it can be done with the existents language
elements, it's well.

>The purpose of the {} in DCGs and the `impure' annotation on calls to impure
>goals is to allow the reader to tell at a glance which calls might do I/O
>or have side-effects and which ones don't.
>
>Yes, these annotations make writing code very slightly more difficult,
>but IMHO they make reading code easier.  And code is read far more often
>than it is written.

It's a good reason. So, instead of suggesting changes to the language, it's
better to write tools that facilites the writing of (easy to read) code.
And that is what I will do.

Nice day and best regards.

+ Gustavo.

--------------------------------------------------------------------------
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