[PD] [text define] functionality for text in structs?

Christof Ressi christof.ressi at gmx.at
Thu Mar 30 15:28:35 CEST 2017

> If it was possible to have an array of pointers,

I get your idea. You can already have [list]s of pointers but this is rather cumbersome. Sometimes I've wished that pointers could be fields in structs (don't know why that's not possible...). Together with a mechanism to compare pointers (right now you can only route them by their type) these could indeed add some new possibilities.

Gesendet: Mittwoch, 29. März 2017 um 15:37 Uhr
Von: "José de Abreu" <abreubacelar at gmail.com>
An: "Derek Kwan" <derek.x.kwan at gmail.com>, "Christof Ressi" <christof.ressi at gmx.at>, pd-list at lists.iem.at
Betreff: Re: [PD] [text define] functionality for text in structs?
Hello, this is my first e-mail on the list, and i don't understand the code of pd or anything like that, but I have an idea. Plus, sorry for bad english.
If it was possible to have an array of pointers, maintained by the user, we could jump to some scalar in the list, say I have 1000 scalars, and an array with pointers to 100th, 200th, 300th, or any combination. This would improve the search.
Maybe this would be a list/array of pointers inside another scalar? What do you think?
Using this design, the user itself can create his own structures with pointers, creating trees,  graphs with the scalars themself.
It make sense?

Em Qua, 29 de mar de 2017 08:47, Derek Kwan <derek.x.kwan at gmail.com[mailto:derek.x.kwan at gmail.com]> escreveu:"Christof Ressi" <christof.ressi at gmx.at[mailto:christof.ressi at gmx.at]> writes:

> I have - and traversing large lists of scalars by pointer can be veeeery slow.
yeahhhh, i figured that could be the case =P

> you could hide the fact that it's a linked list from the user but I
> don't know if that's a good thing to do. It doesn't seem transparent
> to me ("why is accessing the 1000th elements slower than the 1st
> element?").

I suppose you could tell the user via documentation, but then you'd have
go into what a linked list is and why linked list indexing is
O(n) versus array O(1) to explain the speed difference and yeah,
I see your point haha. And it's probably not good either to have a layer
of abstraction that isn't totally necessary either.

> if you don't use the graphical representation, you can just as well
> work with data structure arrays and get fast random access. there is
> one little but unfortunate drawback compared to using lists of
> scalars: drawn instances of array elements don't respond to mouse
> events, making them more or less useless as UI elements. if you
> click/select an element, you only get a pointer to the array, not to
> the element(s). if you click on the canvas, you get pointers to the
> array + all array elements (for whatever reason).
> The right behaviour IMHO would be that clicking/selecting array
> elements gives you pointers to the array *and* the clicked/selected
> element(s). clicking on the empty canvas shouldn't trigger any mouse
> events!
> Apart from that, data structure arrays are quite easy to handle and
> much more efficient than linked lists of scalars

ah, that's interesting. admittedly, i haven't used pd structs that much
in my pd work as of yet but the stuff i want to do seems to be
increasingly lending itself to that (or a similar) sort of paradigm so
i'll keep that in mind!


Derek Kwan

Pd-list at lists.iem.at[mailto:Pd-list at lists.iem.at] mailing list
UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list[https://lists.puredata.info/listinfo/pd-list]

More information about the Pd-list mailing list