Closed andre2007 closed 2 years ago
OK, yeah, I like it. That's useful. My own concern is typing it as ptrdiff_t but storing pointers in it is technically prohibited by the GC rules; the gc might not see it and prematurely free the reference. Could of course just say that's the user's problem... but I might change that.
Gotta run i'll think about this more and probably merge it later tonight or tomorrow, just keep in mind if I change it before tagging the release you might need to adjust your code too..
You are right, the sample coding has this bug. The idea is, in some cases it is sufficient to store just a number which might point to a index of another array. In more sophisticated cases you want to store a object refence. Ptrdiff_t can handle both cases.
Another option would be to have multiple tag fields:
Ptrdiff_t tag
Object tagObject
string tagString
Yeah, could be a fancy union or something too. I think the void* is a reasonable type for the low level then maybe a template interface on top could do better.
I just tagged a thing but haven't had time to work back on this yet, I'll get there eventually though. I have a couple projects with a Thursday deadline so hopefully my time will open up again by then. I probably do have a plan here though.
Well, I'm finally out of the deadline crunch, the stuff that isn't done we're just living without. So got a bit of time here.
Going with just this little change to your PR for now: https://github.com/adamdruppe/arsd/commit/e36512f1d487c9c7fbc6a97842f922aff186f79c
and we'll see about a nicer api in a bit, like adding a runtime type check or something. Just didn't want to keep you waiting another eternity.
Thank you Adam.
Idea is, you can store arbitrary data (e.g. a class pointer) with the item. Therefore while reacting on ChangeEvent, you have all needed data.