[mercury-users] Pred defns

Dominique de Waleffe ddw at miscrit.be
Sat Apr 4 02:24:55 AEST 1998


  >>> "Bart" == Bart Demoen <bmd at CS.kuleuven.ac.be> writes:

Bart> Apart from that: the recent flood of syntax proposals for something
Bart> that Peter Schachte can express concisely with only $ and := is really
Bart> amazing ... and scary !

Agreed.

I've been following this from some distance. My feeling is that we
don't really want to introduce 'global variables' per se because they
quickly make life difficult in large scale developments, but rather,
we, users, want facilities to easily thread more than one accumulator
through the code, and do so while keeping the readability, [we don't
want Perl'ury for sure].

I don't have a proposal yet, though. I'd really prefer an extension
to the DCG notation which has local effects to the introduction of
global variables.  I am wondering if a simple thing like the example
below would not be enough (I use {} around the accs to keep one same
look for the same context, but maybe its bad because with +{}, it
means: take the accs into account, whereas encapsulating subgoals, it
means: igore accs) 

:-pred p(int) + { io:io__state,data:list(int),count:int}.
                  % states: give names to pairs of args
                  % local: usable for implementation of p.
p(X) --> 
     print(X)+{io},
     { print(X,$io,$$io) , $$count = 1+$count}, % or print(X,$io,$$io)+{} ?
     accum(X)+{data},
     p(X-1).

q(..):-p(0,IO1,IO2,[],DataOut,0,Count).
%%% I know this wont stop....

The system would thread all 3 accumulators through the calls, unless
otherwise specified, within {} or +{acc} . The state would be
accessible using $acc.

Does this make enough  sense or does this seem too limiting?

Really, I want to :
- use more than 1 accumulator,
- escape from passing all of them around to all subgoals, 
- be able to reference next and current state by name
- have preference for local effects/transformations 

D.

PS: I won't followup until April 14, I'm off 'til then... 

-- 
Dominique de Waleffe   Email: ddw at acm.org, ddw at myself.com, ddw at miscrit.be
Mission Critical       WWW:   http://www.miscrit.be/~ddw
Phone: +32 2 759 95 60  Fax: +32 2 759 27 60
PGP key fingerprint: F9 CC 23 74 44 62 7C F3  8C 12 DF 71 BB 60 54 98




More information about the users mailing list