[m-dev.] logging proposal
Ian MacLarty
maclarty at cs.mu.OZ.AU
Thu Mar 2 06:47:00 AEDT 2006
On 28 Feb 2006, at 10:40, Mark Brown wrote:
> On 28-Feb-2006, Ian MacLarty <maclarty at cs.mu.OZ.AU> wrote:
>> On Tue, Feb 28, 2006 at 10:16:11AM +1100, Mark Brown wrote:
>>> On 28-Feb-2006, Ian MacLarty <maclarty at cs.mu.OZ.AU> wrote:
>>>> We should aim to seperate out the code that defines the behaviour
>>>> of the application, and the code that is for observing/debugging the
>>>> execution of the program. This proposal doesn't quite get there.
>>>>
>>>> Perhaps a better solution would be to have a `log' (or `debug')
>>>> "goal", so in your code you might have a something like:
>>>>
>>>> debug io.format("X = %i\n", [i(X)])
>>>>
>>>> This makes the distinction much clearer.
>>>
>>> That's a great idea. I think it would be better to explicitly
>>> introduce
>>> the io.state variables though:
>>>
>>> debug [!IO] ( io.format("X = %i\n", [i(X)], !IO), ... )
>>>
>>> so that `debug' is a new quantifier. This would save using explicit
>>> lambda quantifiers or DCG goals (I can't tell from your sample which
>>> you intended).
>>
>> Would you ever have something else besides an I/O state pair in the
>> list after the `debug'?
>
> No, I don't think so.
>
>> If not then the !IO seems a bit redundant. I
>> can't think how having anything else besides !IO would work.
>
> It gives names to the io.state variables. Some people might prefer !S,
> for example.
>
> The alternatives that I can think of are that the body should be a
> DCG-goal
> and that the body should be a higher-order term. The former should be
> avoided because we've found state variable syntax to be much nicer to
> read;
> the latter would be more verbose for anything other than a single call
> in
> the body (which can be curried, and therefore won't need an explicit
> `pred'
> quantifier).
>
I would argue for using a higher-order term. Anything complex should
probably be defined in another predicate anyway (you don't want your
predicate bodies littered with long debug goals).
The thing that bothers me about the 'debug [!IO] (...)' syntax is that
there are always only two variables in the square brackets and square
brackets are normally used for arbitrary length lists. Perhaps it
should be 'debug {!IO} (...)'?
I favor the ho term approach, but I don't feel strongly about it.
Ian.
--------------------------------------------------------------------------
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