[mercury-users] Strange behavior for io__format
Tyson Dowd
trd at cs.mu.OZ.AU
Wed Dec 4 08:51:36 AEDT 2002
On 03-Dec-2002, Pieter Laeremans <pieter at hades.kotnet.org> wrote:
> Hi,
>
> I've found io__format to behave strange
>
>
> This program:
>
> :- module simple.
> :- interface.
>
> :- import_module io.
> :- pred main(io__state::di, io__state::uo) is det.
>
>
> :- implementation.
>
>
> :- import_module string.
> :- import_module list.
> main -->
> io__write("test"),
> io__format("%s", [s("foo"), s("bar")]).
>
Consider:
ArgList = some_incredibly_complicated_computation(2424, 953853278,
123351),
io__format("%s", ArgList, !IO).
Or even consider
read_term_from_input(ArgList, !IO),
io__format("%s", ArgList, !IO).
> Shouldn't the compiler warn for this kind of error ?
Cannot be done in general. The interface to format decouples the
formatting string from the data, so it's up to you to make sure they are
in sync.
Mercury provides strong type, mode and determinism checking and
inference. If you can't encode it in these systems, it doesn't get
checked.
It often happens that after such nice type mode and determinism checking
you wonder why the compiler can't just catch all your errors... ;-)
Tyson.
--------------------------------------------------------------------------
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