[mercury-users] A subtlety about DCG variable threading

Terrence Brannon princepawn at earthlink.net
Thu Apr 26 20:17:14 AEST 2001


It was my understanding that the only terms in a clause which would
not receive DCG threading were those that were escaped with { }.

Thus in run/3 below, I am confused as to why process/3 is not
process/5 (in other words, is immune the DCG threading but not
escaped) but io__write_string/3 is io__write_string/3 (ie, it is not
immune to DCG threading and this is not surprising because it is not
escaped. 

My guess is that the process/3's modes are not compatible with those
of the head of the DCG (specifically, they are not di and uo) and that
somehow Mercury selectively engages in the biblical act of Passover on
them because of this, the bloody mark on the door in this case being
incompatible modes.


 > 	:- pred main(io__state::di, io__state::uo) is det.
 > 
 > 	:- implementation.
 > 	:- import_module lexer, std_util, list, multi_map.
 > 
 > 	main -->
 > 		run(initial_db).
 > 
 > 	:- mode run(in, di, uo) is det.
 > 	run(DB0) -->
 > 		lexer__get_token_list(Tokens),
 > 		(if { parse(token_list_to_list(Tokens), Command) } then
 > 			process(Command, DB0, DB),
 > 			run(DB)
 > 		else
 > 			io__write_string("syntax error\n")
 > 		).
 > 

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