Ah, so is the [pointer] object the same thing as a C pointer (*ptr) traversing a linked list? I knew the had the same name, but since so many things are named strangely in Pd (right Matju?) I couldn't be sure.
I guess the difficult thing for me with data structures is there is only the ability to traverse and step ahead, so it seems that there will be a lot of [until] use to get to specific portions of the data. There is no step backwards or prepend feature, or push/pop stuff either, which would be nice. I guess they'd have to be abstractions? And what would be the most efficient way to keep track of things, some kind of construct using [until] or a counter and comparing that with an index value in the scalar? Arrrg.
~Kyle
On 9/12/06, Mathieu Bouchard matju@artengine.ca wrote:
On Tue, 12 Sep 2006, Kyle Klipowicz wrote:
What I don't understand is why there is a completely different atom, pointer, to index the datastructures. Why not just use an integer? Is it faster?
This is because Miller is still using linked-lists for a bunch of things in Pd. Getting to element number N in a linked-list takes N steps, if you don't have a pointer that gives you direct access. So, yes, it's faster.
I won't advocate switching to integers and B-trees or something, because there's also an advantage to using pointers: if you delete or insert elements in a list, all integers pointing to a later part of the list will get shifted to different elements; with pointers it's not the case.
(a B-tree is one kind of array-like structure in which inserting and deleting is a lot faster than in regular arrays. it's made using several levels of nested arrays. This is not the same as a binary-tree, which also can be used as a fast-inserting array, but which is slower than a B-tree)
(Pd could be reimplemented with a variant on the integer system in which integers wouldn't indicate the order of the objects, but i don't think that it's really worth it.)
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju | Freelance Digital Arts Engineer, Montréal QC Canada