[mercury-users] Partially instantiated modes

David Overton dmo at cat.cs.mu.OZ.AU
Fri Nov 12 15:58:05 AEDT 1999


On Fri, 12 Nov, 1999 at 12:36:16PM EST, Robert Ernst Johann JESCHOFNIK wrote:
> On Fri, 12 Nov 1999, Thomas Conway wrote:
> 
> > Actually I lied slightly - the code was already a DCG wrt the io__state.
> > This is (as Peter Schachte has pointed out more than once) the problem
> > with DCGs. Maybe there is something to his Syntactically Quiet Threading
> > (TM) (aka global variables) after all....
> 
> Here is a message that I saved, knowing that it would be usefull one day
> :)
> 
> >From Herr Conway himself, 13th May 1999:
> FWIW, since one ends up wanting a mini-dcg inside another predicate,
> here is a programming trick I use:
> 
>         ... some non-dcg code ...
>         call((pred(in, out) is det -->
>                 set_a(1),
>                 set_b('c'),
>                 set_c("dee"),
>                 set_d(X)
>         ), OldState, NewState),
>         ...
> 
> 
> Why not reorder the variables, and then do a `call' like this to thread
> your states through?
> 

This won't work in this case because the lambda expression would need
to bind non-local variables.  You _could_ pass each of these variables
as an argument to the higher order call, but that's maybe getting a
bit ugly:

	call((pred(A1::out, A2::out, A3::out, ..., in, out) is det -->
		new_named_var("V1", A1),
		new_named_var("V2", A2),
		new_named_var("V3", A3),
		...
	), V1, V2, V3, ..., VarSet0, VarSet1)


David
-- 
David Overton       Department of Computer Science & Software Engineering
PhD Student         The University of Melbourne, Australia
+61 3 9344 9159     http://www.cs.mu.oz.au/~dmo
--------------------------------------------------------------------------
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