Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!rpi!nisc.nyser.net!cmx!goedel!hamid From: hamid@goedel.uucp (Hamid Bacha) Newsgroups: comp.lang.prolog Subject: Re: assert/record Message-ID: <2143@cmx.npac.syr.edu> Date: 14 Dec 89 23:59:04 GMT References: <5929@sun.acs.udel.edu> Sender: usenet@cmx.npac.syr.edu Reply-To: hamid@logiclab.cis.syr.edu (Hamid Bacha) Organization: Logic Lab, CIS Dept., Syracuse University Lines: 36 In article <5929@sun.acs.udel.edu> jms@sun.acs.udel.edu (John Milbury-Steen) writes: >We have some applications with large amounts of data, >that must be modified a lot during run time. Is >it more efficient to use "record" or "assert?" > >If, for example, you are storing the fact that >Fido is brown, is it better to say: > record(fido, color(brown), _) >or to say: > assert(fido(color(brown))) > >Assume the program knows about 30 attributes of 5000 dogs. >(My applications are not really canine). > >Are recommendations different for Arity Prolog and >Quintus? If your Prolog system is based on an incremental compiler (e.g. ALS-Prolog), you may be better off using record. Assert and retract involve compilation followed by decompilation of the given term. These are two very expensive operations which should be avoided unless you intend to execute the term as a Prolog clause. >I think asserting might be just as efficient, because >once you know the dog, you can find the attribute >quickly via first-argument indexing. If you record, Most Prolog systems do not do first (or Nth) argument indexing on dynamic predicates.