[PD-dev] strings

Bryan Jurish moocow at ling.uni-potsdam.de
Sun Dec 17 22:03:14 CET 2006


moin Martin, moin list,

On 2006-12-17 21:46:50, Martin Peach <martin.peach at sympatico.ca> appears 
to have written:
> Bryan Jurish wrote:
>> On 2006-12-17 03:09:19, Martin Peach <martin.peach at sympatico.ca> 
>> appears to have written:
>>> A string could be considered unused when its length is set to 0. 
>>> Memory would need to be dynamically allocated in small blocks. The 
>>> API should return "no method for string" if the external doesn't 
>>> implement strings.
>>
>> ... which wouldn't get us true strings in the mathematical sense of a 
>> free monoid <Alphabet,concat()>, since the empty string is the 
>> identity element for concat()...
>>
> Yes, I agree there should be no restriction on empty strings. I also 
> think there is no need to destroy strings except when the patcher is 
> closed, so it's not really an issue.

if by "destroy" you mean de-allocation of the string struct itself (i 
assume you do; your suggestion looks a lot like a glib GString btw, 
which is im(ns)ho a good general purpose c string struct), and if a 
string therefore winds up being just something like a symbol with a 
volatile value (i.e. doesn't get written to the symbol table), then i agree.

what i think we need to avoid with strings (i don't think anyone has 
suggested otherwise, i'm just stating the obvious) is symbol-style 
permanent allocation for every string *value*.  string "variables" 
could/should be handled like any other pd atom: the external which 
creates them is responsible for (de-)allocation, which would wind up 
doing what you suggest and freeing any allocated memory when the 
responsible object is destroyed (provided the object doesn't leak 
memory, but i think we can assume c programmers are used to keeping 
track of such things -- ymmv).

in fact, this is how [any2string] handles things, in its ugly 
list-of-floats way...

marmosets,
	Bryan

-- 
Bryan Jurish                           "There is *always* one more bug."
jurish at ling.uni-potsdam.de      -Lubarsky's Law of Cybernetic Entomology




More information about the Pd-dev mailing list