[m-rev.] for review: arrays and the debugger
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Jun 18 14:22:29 AEST 2001
On 18-Jun-2001, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> I wrote:
> > library/std_util.m:
> > Add a new predicate, limited_deconstruct, which usually does what
> > deconstruct does, but fails (and does not allocate any memory) if
> > the arity of the supplied term is beyond a given limit.
>
> On 16-Jun-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > Why not just use functor/3 to test the arity,
> > and then call deconstruct/4 or not depending on the arity returned by
> > fnuctor/3?
>
> Performance. Doing that would require interpreting the RTTI structures twice.
> For discriminated union types, one of the most common data structures, that is
> reasonably expensive. The extremely small risk of bumping into the limit is
> not worth it.
Hmm... limited_deconstruct would only be used when pretty-printing,
wouldn't it? I don't think that is likely to be performance-critical.
Also, you don't need to do the test for all types, it's enough to do it
just for arrays. For other types the size is unlikely to be large and so
you can test the arity returned by deconstruct. Pretty-printers generally
need to check for and handle arrays specially anyway, so there need not be
any performance impact in the common case where the data structures are
not arrays.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list