Is there a way to override list.Add() to add some custom behavior to it?
And as a side question, if I do list+=something, will that still call list.Add() like list.Add(something) would?
No.
You are probably going to want to wrap a list in a datum to handle this kind of behavior: collection Unfortunately, this will not permit you to use operators with the collection anymore, so you should use collection.data directly if you have a lot of non-specialized transactions, otherwise you are going to see a speed hit compared to using a normal list. This is good for things like keeping a list ordered. |
Kaiochao wrote:
No. You'll have to make your own global proc, or something. To remove all null references in the list from atoms that have ceased to exist |
Someone in the other thread took the time to give you a link that shows you how to do this:
http://www.byond.com/forum/?post=1468645#comment8253922 |
Ter13 wrote:
Someone in the other thread took the time to give you a link that shows you how to do this: Yes and I tried this: datum/Del() But it shoots world.cpu to like 200% so it is unusable. |
Not to talk badly about the dead, but if Falacy wrote it... Probably best to ignore it. Falacy is partially to blame for a large number of the bad habits floating about here.
Use Lummox's example from that thread, not Falacy's. |
I would but I don't understand where or in what context he is saying to use it.
|
Well, it's not going to happen automatically. With any kind of ease. You are going to need to set up Lummox's approach in some type of a list cleaning function, and you are going to want to call that before you interact with the list after a specified delay.
The cleanest approach I can think of to automatically handle this behavior would involve circular references, which are probably a bad idea as they can cause the garbage collector to fail. |
What is the custom behavior you want?