I suppose since we're doing this about feature requests, I'd like to ask about deleting instances of structs in linked lists =).
I've read through the list archive and seen this pop up a few times, one of the issues being brought up being stale pointers if I recall correctly. Is there any progress on this? Would it be possible to just copy over the data from the next node (if it exists) into the requested deleted node and dealloc the original next node? And if a current [pointer] is empty/stale, the next [pointer] the same, just reset to the head as a failsafe? Admittedly, I'm not very familiar with the mechanisms behind [pointer]s so I could be talking complete nonsense so apologies in advance...
I suppose that this is a somewhat unrelated question, but what is the [scalar] object supposed to do? Is it just a specific instance of a struct in the linked list?
I'd also echo William's words and say thanks for Pd, Miller =)
Derek
but what is the [scalar] object supposed to do? Is it just a specific instance of a struct in the linked list?
What it does is create its own subpatch and append a single scalar of a given template (struct). This way it's a bit like the table object. I often use it when I don't care about the graphical representation and just want to use a struct as a container of heterogenous data. I think it's meant to get an interface similar to [array] and [text] in the future, but even in its current rudementary form it's quite useful.
Regarding your request of a 'delete' method:
We can already delete scalars from the glist by selecting their graphical representation in the subpath and hit `del', just with any other object. Pointers will get marked invalid (error message about pointer being 'empty' or 'stale') and therefore stay safe. So the functionality is there, we just need a way to delete a scalar by pointer.
in the meantime, here's a little hack how to delete specific scalar instances (as long the scalar has a drawing instruction and is visible + editable). get the scalar's x + y coordinates with [get], then send following message to the subpatch containing the scalar: [mouse x y 1 0, mouseup x y 1, key 1 8 0(
Christof
Gesendet: Dienstag, 03. Januar 2017 um 07:04 Uhr Von: "Derek Kwan" derek.x.kwan@gmail.com An: pd-list@lists.iem.at Betreff: [PD] Request - Deleting struct instances, progress?
I suppose since we're doing this about feature requests, I'd like to ask about deleting instances of structs in linked lists =).
I've read through the list archive and seen this pop up a few times, one of the issues being brought up being stale pointers if I recall correctly. Is there any progress on this? Would it be possible to just copy over the data from the next node (if it exists) into the requested deleted node and dealloc the original next node? And if a current [pointer] is empty/stale, the next [pointer] the same, just reset to the head as a failsafe? Admittedly, I'm not very familiar with the mechanisms behind [pointer]s so I could be talking complete nonsense so apologies in advance...
I suppose that this is a somewhat unrelated question, but what is the [scalar] object supposed to do? Is it just a specific instance of a struct in the linked list?
I'd also echo William's words and say thanks for Pd, Miller =)
Derek
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
in the meantime, here's a little hack how to delete specific scalar instances (as long the scalar has a drawing instruction and is visible + editable). get the scalar's x + y coordinates with [get], then send following message to the subpatch containing the scalar: [mouse x y 1 0, mouseup x y 1, key 1 8 0(
what you can also do is to put a "vis 1" before and "vis 0" after those commands. in my experience, it opens up and closes the window so fast, that one doesn't see it happening. (I didn't try it with pointers, just with normal objects - but that's the same for the mouse) it should work even if the scalar is outside the window borders.
regarding the drawing instruction, don't all scalars have the x y coordinates, even if they're not defined in the template? in that case, the scalars without a drawing should be automatically at the coordinates 0 0 - which can be dangerous in case you use your scalars just to store (and not display) data, because all of them will be positioned at 0 0. all this I can't test now, I'm just replying from memory.
I suppose since we're doing this about feature requests, I'd like to ask about deleting instances of structs in linked lists =).
that has been asked for a while. also with a "previous" method, instead of just "next".
Best,
jmmmp
yeah, "vis 1" and "vis 0" is necessary if the window is not visible. Forget to mention that. Thanks!
Gesendet: Dienstag, 03. Januar 2017 um 12:29 Uhr Von: "João Pais" jmmmpais@gmail.com An: "Christof Ressi" christof.ressi@gmx.at Cc: "Derek Kwan" derek.x.kwan@gmail.com, "Jonathan Wilkes via Pd-list" pd-list@lists.iem.at Betreff: Re: [PD] Request - Deleting struct instances, progress?
in the meantime, here's a little hack how to delete specific scalar instances (as long the scalar has a drawing instruction and is visible + editable). get the scalar's x + y coordinates with [get], then send following message to the subpatch containing the scalar: [mouse x y 1 0, mouseup x y 1, key 1 8 0( what you can also do is to put a "vis 1" before and "vis 0" after those commands. in my experience, it opens up and closes the window so fast, that one doesn't see it happening. (I didn't try it with pointers, just with normal objects - but that's the same for the mouse) it should work even if the scalar is outside the window borders. regarding the drawing instruction, don't all scalars have the x y coordinates, even if they're not defined in the template? in that case, the scalars without a drawing should be automatically at the coordinates 0 0 - which can be dangerous in case you use your scalars just to store (and not display) data, because all of them will be positioned at 0 0. all this I can't test now, I'm just replying from memory. > I suppose since we're doing this about feature requests, I'd like to ask
about deleting instances of structs in linked lists =).
that has been asked for a while. also with a "previous" method, instead of just "next". Best, jmmmp
Thanks! Didn't think about simulating motion and deleting the GUI way
And thanks about [scalar]. Seems like it might be a good way of doing multidim arrays.
yeah, "vis 1" and "vis 0" is necessary if the window is not visible. Forget to mention that. Thanks! Â
And it needs to be in edit mode, correct? So editmode 1 after vis 1, editmode 0 before vis 0. Doesn't seem to work otherwise...
regarding the drawing instruction, don't all scalars have the x y coordinates, even if they're not defined in the template? in that case, the scalars without a drawing should be automatically at the coordinates 0 0 - which can be dangerous in case you use your scalars just to store (and not display) data, because all of them will be positioned at 0 0.
if you're not using them to display, there's no drawing commands so it wouldn't do anything anyways. If there is a draw command, then it looks like you can't specify any particular element since they're all being drawn on 0 0 and deleting at 0 0 deletes the head of the list since it's at the top. So not particularly dangerous,... but not particularly directable either =)
Derek
which can be dangerous in case you use your scalars just to store (and not display) data
even if you don't really want to display your data, it doesn't hurt to create a dummy drawing instruction (could be a polygon with a single constant point). When appending scalars, just keep track of the index with a counter and set the x or y value to some multiple of the current index. this way, all scalars are seperated nicely (given that the polygon is small enough so scalars don't overlap).
By the way, I usually try to avoid deleting scalars because it invalidates all pointers. I rather do the following: In the template I have a special field which tells if a scalar is active. drawing instructions use this field to toggle its visibility. If I want to 'construct' a new scalar, I just search the subpatch for the first inactive scalar. If there is none, I append a new scalar. When I want to 'destruct' a scalar, I just set the field to zero (false). Basically it works like an object pool. You could also store pointers to recently 'destructed' scalars in a kind of free-list, so that finding available scalars is easier and more efficient. Obviously, the pool never shrinks but that little bit of extra memory doesn't really matter.
Christof
Gesendet: Dienstag, 03. Januar 2017 um 23:13 Uhr Von: "Derek Kwan" derek.x.kwan@gmail.com An: "Christof Ressi" christof.ressi@gmx.at, jmmmpais@gmail.com Cc: pd-list@lists.iem.at Betreff: Re: [PD] Request - Deleting struct instances, progress?
Thanks! Didn't think about simulating motion and deleting the GUI way
And thanks about [scalar]. Seems like it might be a good way of doing multidim arrays.
yeah, "vis 1" and "vis 0" is necessary if the window is not visible. Forget to mention that. Thanks!
And it needs to be in edit mode, correct? So editmode 1 after vis 1, editmode 0 before vis 0. Doesn't seem to work otherwise...
regarding the drawing instruction, don't all scalars have the x y coordinates, even if they're not defined in the template? in that case, the scalars without a drawing should be automatically at the coordinates 0 0 - which can be dangerous in case you use your scalars just to store (and not display) data, because all of them will be positioned at 0 0.
if you're not using them to display, there's no drawing commands so it wouldn't do anything anyways. If there is a draw command, then it looks like you can't specify any particular element since they're all being drawn on 0 0 and deleting at 0 0 deletes the head of the list since it's at the top. So not particularly dangerous,... but not particularly directable either =)
Derek
-- Derek Kwan www.derekxkwan.com