[mercury-users] State variables as function arguments.

Julian Fondren ayrnieu at gmail.com
Sat Feb 10 02:52:21 AEDT 2007

The Language Reference Manual says:

  `!X' may not appear as an argument in a function application
  since this would not make sense given the usual interpretation
  of state variables and functions.

What is the 'usual interpretation' of these?  I've regarded
state variables as only a convenience -- so that I can instead

  :- func test(string, io, io) = int.
  :- mode test(in, di, uo) = out is det.
  test(S, IO1, IO) = test(S, 1, IO1, IO).

(which Mercury doesn't mind) say:

  test(S, !IO) = test(S, 1, !IO).

Actual code that I fixed to deal with this now looks like

        or_die("dir", readable(forget_dir, IO1, IO2), IO2, IO3),
        or_die("forget", readable(forget, IO3, IO4), IO4, IO5),

-- doing that because I assumed that the error was spurious,
caused by another error that I hadn't fixed yet.

Of course, I don't mean to just complain -- I've already
restructured that code once to deal with discovering that
IO functions can't be semidet.  I *would* like to know what
the usual interpretation is, where my 'convenience' interpretation
led me into trouble.

Thanks, Julian.
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au

More information about the users mailing list