[mercury-users] A thought on state variables and the library

Julien Fischer juliensf at csse.unimelb.edu.au
Tue Feb 20 23:04:47 AEDT 2007


On Tue, 20 Feb 2007, Julian Fondren wrote:

> On 2/19/07, Peter Schachte <schachte at csse.unimelb.edu.au> wrote:
>> doug.auclair at logicaltypes.com wrote:
>> > "Use state variables; do not use DCGs (except for scanners/parsers)"
>> Don't forget output generation; DCGs are very good for that, too.
>
> And compiler/bytecode.m -- DCGs are very good for that, too.
>
> (So far, I think 'go with state variables' a good bias, which seems
> to lead to less hassle and redecision-due-to-unacceptable-ugliness
> when it comes time to add more complexity to a clause.)

DCGs are okay where the state needs to be threaded through every goal,
however, particularly with threading the I/O state, you end up having
to put DCG escapes around lots of goals which not only looks ugly
but is also a source of annoying little syntax errors.

DCG escapes are a bit troublesome in Mercury because {...} is also
the syntax for tuples.  IMO, they are best avoided except in a small
number of circumstances.

Julien.


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