[m-dev.] io syntax change
Ralph Becket
rbeck at microsoft.com
Sun Dec 10 04:35:34 AEDT 2000
> Dominique and I were discussing today about using the ideas from the
> purity syntax for predicates which do io.
>
> For example:
>
> :- io pred write_char_list(list(char)::in) is det.
> :- io pred write_char(list(char)::in) is det.
>
> write_char_list([]).
> write_char_list([H|T]) :-
> io write_char(H),
> io write_char_list(T).
>
> The advantages of this syntax are:
> * it is quite a simple syntactic transformation
> * it frees up the DCG notation for some other state
> * in a lot of ways io is such a special case that IMHO having a
> seperate syntactic construct is a good thing.
> * I find it quite light weight
>
> The disadvantages are
> * I haven't thought about it a lot
> * does it interact well with higher order code
This sounds like a special case of the extended DCG (EDCG) stuff somebody
was talking about way back when.
I can't remember exactly what the syntax was, but the annotation
went entirely on the pred declarations, something like:
:- edcg_args io == (io__state, io__state).
:- edcg_mode io == (di, uo).
:- pred io__write_string(string) + io.
:- mode io__write_string(in) + io is det.
...
:- pred foo(string) + io.
:- mode foo(in) + io is det.
foo(S) -->>
io__write_string("here's a string: "),
io__write_string(S),
io__nl.
A pred could have multiple hidden arguments.
My main objection to the scheme was that you had to know which
hidden arguments were changed by each pred; I like your idea of
explicitly annotating calls, so we might have something like
this:
:- pred bar(string) + acc + io.
:- mode bar(in) + acc + io is det.
bar(S) -->>
[io] io__write(""blah"),
[acc] do_something(S),
[io, acc] finish_up.
Another problem (IMHO) was the syntax for accessing hidden args
directly was pretty ugly (definite Perl influences).
Ralph
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list