>>>>> "RR" == Robin Redeker <[EMAIL PROTECTED]> writes:

  RR> I don't think circular references are used that much. This is
  RR> maybe something a programmer still has to think a little bit
  RR> about.  And if it means, that timely destruction maybe becomes
  RR> slow only for the sake of collecting circular references... don't
  RR> know if thats a big feature.

ever do any callback stuff? an object needs to be called back from a
service (say a i/o handler). it must pass itself to the service to be
stored there. the service returns a handle which needs to be stored in
the object so it can be used to manage it (start/stop/abort/etc.). there
is a quick circular ref.

now, weakrefs can fix that but i don't like that solution. GC fixes it
with no problems at all. you can just drop the object and it and the
service handle (whatever that is) will be reclaimed soon enough.

and there are many useful data structures that need backrefs. not
everything can be represented in clean tree. i won't go into these but
there is plenty of literature on them.

by far the biggest problem of refcounting (from the coder's perspective,
not it speed or internal debugging stuff) is circular refs. i currently
require explicit destroys to make sure i break them. i could (maybe i
will one day) switch to weakrefs. but i would much prefer to not know or
care about circular refs at all and allow stuff be collected when they
can.

but there is another reason i need explicit destroys, the service must
be shut down for a given handle. you can't have a select loop running
with lots of dead sockets and callbacks to nowhere. even weakrefs and
refcounting can't fix this and neither can GC. waiting later to close
down external resources like DB handles can work but select loops need
finer control.

in any case, i am totally for dan's decision to go with GC. it removes a
major weakness in perl's memory management. refcounting just doesn't
win in speed nor in internal complexity nor in safety of coding.

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org

Reply via email to