[PD] (breaking symbols) was Re: find a list of numbers in a text file

Mathieu Bouchard matju at artengine.ca
Tue Sep 6 23:39:33 CEST 2011

On Mon, 5 Sep 2011, Hans-Christoph Steiner wrote:
> Unfortunately terms to describe typing do not have clear boundaries.  But 
> which words are used are not important to me, as long as the meaning gets 
> across.  Does "dynamic typing" make you happy?  Python, Ruby, Perl, Tcl, and 
> to a large extent Pd, all have "dynamic typing".

A lot like to say "dynamic typing", but it's too vague. Thinking about 
more precise words helps noticing facts about programming languages.

I found that there's a big distinction to be made between 4 kinds of 
typing, and I think that it's an interesting tool to compare approaches 
and languages :

1. typed expressions : compile-time checks to enforce correct types. 
That's much of the reason you have to do many pointer casts in C or Java.

2. typed variables : there may be type-checks at the time of storing into 
variables or passing parameters.

3. typed values : a piece of data has a tag onto it that tells the type of 
the data, in case the type of the variable isn't specific enough.

4. typed use : the type is what I ask the piece of data to act like.

A language may have any combination of the four, but typically, C is 
naturally 1&2, C++ is naturally 1&2&3, though automatic casts may make it 
feel a bit like it is #4 too. Perl is mostly about 2&3&4, 
Python/Ruby/Lua/Javascript/Smalltalk are 3, plain Tcl is almost only 4, 
Tcl with objects is 3&4.

I didn't take that from any textbook, so I can't give a reference. That 
categorisation is mine. (If anyone knows a similar categorisation, I'd 
like to know)

>>> So in the sense of Pd, anything that can be intepreted as a number 
>>> should be. But that's in conflict with having symbols that have things 
>>> that can be intepreted as a number.  So make Pd consistent, either it 
>>> needs to be illegal to have symbols that can be interpreted as a 
>>> number,
>> This could break some existing patches.
> Do you have an examples?  That would be very helpful.  Off the top of my 
> head, it seems that it would only break patches that rely on errors, which is 
> not a very common situation.

Take any method that needs a A_SYMBOL argument, and give it the result of 
[makefilename] that is an A_FLOAT because it would have been an illegal 
A_SYMBOL. The thing is, I really needed to give that number as a string 
for printing and, if there is not the automatic conversions were are 
talking about (or if the externals don't use it yet), then you won't be 
able to give it the string "123" or whatever.

Note that even with automatic conversions enabled, there wouldn't be a way 
to do something like [makefilename %.2f] or [makefilename %.8f] in a 
reliable way. How would a [text3d] or [netsend] or [string2bytes] know how 
many digits it should send ? It will never know.

| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC

More information about the Pd-list mailing list