Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!hao!noao!arizona!debray From: debray@arizona.edu (Saumya Debray) Newsgroups: comp.lang.prolog Subject: Re: Destructive predicates (random musings - part-I). Message-ID: <4087@megaron.arizona.edu> Date: 1 Mar 88 15:16:21 GMT References: <7289@agate.BERKELEY.EDU> Organization: U of Arizona CS Dept, Tucson Lines: 28 Keywords: Destructive predicates, LISP vs PROLOG Philosophy Summary: need to consider sharing between structures lagache@violet.berkeley.edu (Edouard Lagache) writes: > [ ... ] what would be wrong with having a "fully" destructive > append that would be used only in the situations without reversibility > and backtracking. In general, it isn't enough to have directionality and determinism. You have to make sure that the "old" value of the (sub)structure being destructively assigned to isn't accessible from anywhere else. In other words, it isn't enough to combine mode and determinacy analysis with a simple live variable analysis to figure out when a structure can be reused: sharing patterns between structures have to be looked at as well. As an example, consider p(X,Y,Z,W) :- W = [a|X], append(X,Y,Z). where p/4 has the mode -- then, given the usual implementation of unification for the literal "W = [a|X]", append/3 cannot use destructive assignment even though its use in this context is directional and deterministic. Maurice Bruynooghe has done some work on static analyses to detect situations where destructive assignment can be introduced as a compiler optimization, see his paper in SLP87. -- Saumya Debray CS Department, University of Arizona, Tucson internet: debray@arizona.edu uucp: {allegra, cmcl2, ihnp4} !arizona!debray