circular-reference

Is it possible to create circular references in Clojure?

≯℡__Kan透↙ 提交于 2019-12-04 15:39:16
问题 Ignoring native interop and transients, is it possible to create any data structures in Clojure that contain direct circular references ? It would seem that immutable data structures can only ever contain references to previous versions of themselves. Are there any Clojure APIs that could create a new data structure that has a reference to itself ? Scheme has the letrec form which allows mutually recursive structures to be created - but, as far as I can tell, Clojure does not have anything

Injecting EntityManager-dependend service into Listener

核能气质少年 提交于 2019-12-04 12:11:51
I am trying to inject one of my services into an EntityListener in order to call some application specific behaviour when an entity gets updated. My Logger service, used to store events in a LogEntry entity in my database: class Logger { /** * @var EntityManager $manager The doctrine2 manager */ protected $manager; //... } The listener: class EntityListener { public function __construct(Logger $logger) { $this->logger = $logger; // ... } } And the service definitions in my service.yml : listener: class: Namespace\EntityListener arguments: [@logger] tags: - { name: doctrine.event_listener,

Java circular references

社会主义新天地 提交于 2019-12-04 04:37:19
问题 In the project im working on, people wrote services class to access DAO. Almost every business object has it's own service which use it's own DAO. On some services, we are using references to other services. At the moment, people are instantiating needed services inside the constructor. But now, I have trouble because service A needs service B and service B needs service A so a call to either constructor results in stack overflow ... Example (pseudo-code) : //Constructor of OrderService

Symfony serializer - set circular reference global

℡╲_俬逩灬. 提交于 2019-12-04 02:59:05
Is there any way to set the circular reference limit in the serializer component of Symfony (not JMSSerializer) with any config or something like that? I have a REST Application with FOSRestBundle and some Entities that contain other entities which should be serialized too. But I'm running into circular reference errors. I know how to set it like this: $encoder = new JsonEncoder(); $normalizer = new ObjectNormalizer(); $normalizer->setCircularReferenceHandler(function ($object) { return $object->getName(); }); But this has to be done in more than one controller (overhead for me). I want to set

Garbage collection in Perl

我们两清 提交于 2019-12-03 16:14:26
问题 Unlike Java, Perl uses reference count for garbage collection. I have tried searching some previous questions which speak about C++ RAII and smart pointers and Java GC but have not understood how Perl deals with the circular referencing problem. Can anyone explain how Perl's garbage collector deals with circular references? Is there any way to reclaim circular referenced memory which are no longer used by the program or does Perl just ignores this problem altogether? 回答1: According to my copy

In Nodejs, when I console.log a req object, what does [Circular] reference? How to determine that

我们两清 提交于 2019-12-03 15:44:37
问题 In Nodejs, when I console.log a req object, what does [Circular] mean? Here's an example console.log(req) against a basic nodejs example. Notice the request.socket._readWatcher.socket is a [Circular]. Does that mean it refers to itself? How can I dereference that? { socket: { bufferSize: 0, fd: 7, type: 'tcp4', allowHalfOpen: true, _readWatcher: { socket: [Circular], callback: [Function: onReadable] }, destroyed: false, readable: true, _writeQueue: [], _writeQueueEncoding: [], _writeQueueFD:

I have a circular reference. How can I create a weak reference in Objective-C?

蓝咒 提交于 2019-12-03 09:51:20
I'm working on an iPhone application. I have an object of class Row that needs to release numerous objects of the class Block . Every Block currently has a property that retains an instance variable of class Row . @interface Block : UIImageView { Row *yCoord; } @property (nonatomic,retain) Row *yCoord; @end Every Row contains an NSMutableArray of these Blocks. @interface Row : NSObject { NSMutableArray *blocks; } -(void)addBlock:(Block*)aBlock; @end @implementation Row -(void)addBlock:(Block*)aBlock { [blocks addObject:aBlock]; aBlock.yCoord = self; } @end I understand that this is a circular

Is it possible to create circular references in Clojure?

喜欢而已 提交于 2019-12-03 09:43:52
Ignoring native interop and transients, is it possible to create any data structures in Clojure that contain direct circular references ? It would seem that immutable data structures can only ever contain references to previous versions of themselves. Are there any Clojure APIs that could create a new data structure that has a reference to itself ? Scheme has the letrec form which allows mutually recursive structures to be created - but, as far as I can tell, Clojure does not have anything similar. This question is related to porting Clojure to iOS - which does not have garbage collection, but

Is there a way to detect circular arrays in pure PHP?

不羁岁月 提交于 2019-12-03 05:49:14
问题 I'm trying to implement my own serialization / var_dump style function in PHP. It seems impossible if there is the possibility of circular arrays (which there is). In recent PHP versions, var_dump seems to detect circular arrays: php > $a = array(); php > $a[] = &$a; php > var_dump($a); array(1) { [0]=> &array(1) { [0]=> *RECURSION* } } How would I implement my own serialization type of method in PHP that can detect similarly? I can't just keep track of which arrays I've visited, because

Garbage collection in Perl

点点圈 提交于 2019-12-03 05:33:05
Unlike Java, Perl uses reference count for garbage collection. I have tried searching some previous questions which speak about C++ RAII and smart pointers and Java GC but have not understood how Perl deals with the circular referencing problem. Can anyone explain how Perl's garbage collector deals with circular references? Is there any way to reclaim circular referenced memory which are no longer used by the program or does Perl just ignores this problem altogether? According to my copy of Programming Perl 3rd ed. , on exit Perl 5 does an "expensive mark and sweep" to reclaim circular