# $this->this and avoiding circular references

- Thread: https://externals.io/message/21128
- Original archive: https://news-web.php.net/php.internals/21128
- Started by Andi Gutmans on 2005-12-09T06:00:52+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #21128 — Andi Gutmans — 2005-12-09T06:00:52+00:00

URL: https://externals.io/message/21128#21128

Hey,

re: limiting factor I don't completely disagree but then again, in 
most cases, it's possible to design the app in a way which resolves 
the problem.
As to weak references, you could do weak references in PHP just by 
using the indirect property access. Might not be perfect but it's quite doable.

Andi

At 09:21 PM 12/8/2005, Alan Pinstein wrote:
> > […]
>
>sure, of course...
>
> > […]
>
>Well I'd say that using a PHP-CLI script to import bulk data is a
>real-life usage and this is definitely a limiting factor. Do you
>disagree?
>
> > […]
>
>Well, Cocoa solves the problem in a manner I consider quite graceful.
>In 99% of situations, you don't touch memory management and things
>work themselves out like in PHP. However, there is a concept of a
>WEAK REFERENCE (a non-ref-counted ptr to the object) that is used
>*specifically* in these cases to prevent circular references.
>
>With this type of system, there is no additional overhead because the
>GC doesn't have to "detect" circular references and determine if the
>objects are orphaned but deadlocked... instead this is a situation
>left to the developer to manage.
>
>Now I understand that PHP isn't Obj-C and it's a higher-level
>language and that's fine.
>
>However, my question, which still remains unanswered, is that I've
>found a way that "seems" to create a weak reference and I'm simply
>asking if what I am doing is condoned or just lucky (and thus a bad
>idea that will probably break in the future)...
>
>And, if it's just lucky, then what is the solution to the problem? Am
>I just SOL? Is the answer simply that if you *need* to create
>circular references in PHP, then you *must* accept memory leakage?
>
>Alan
