Hi,
I would like to check, if $0 was passed as an argument to an abstraction. The usual idiom is:
[loadbang]
|
[f $1] assuming, $0 was passed as $1
|
[select 0]
|
this is $0 now
Now of course this fails, if $0 also can be zero itself. I know, that currently this is very unlikely, because $0 starts at 1000 and grows. But it would be great if possible future changes to the $0-implementation would still rule out 0 as a value for $0, so that the test from above will keep working.
Frank Barknecht _ ______footils.org_ __goto10.org__
That's funny... the reason $0 starts at 1000 and not 0 is because in Max the $ variables were printffed into the boxes themselves and I wanted to keep all the $ variables (at least the first 8999 of them) to the same width as a character string.
Anyway, $0 uses true integers, so that it's unlikely they will ever reach zero (you'd have to fill your address speace 100s of times)... so I think you're safe.
cheers Miller On Sun, Aug 13, 2006 at 10:04:02AM +0200, Frank Barknecht wrote:
Hi,
I would like to check, if $0 was passed as an argument to an abstraction. The usual idiom is:
[loadbang] | [f $1] assuming, $0 was passed as $1 | [select 0] | this is $0 now
Now of course this fails, if $0 also can be zero itself. I know, that currently this is very unlikely, because $0 starts at 1000 and grows. But it would be great if possible future changes to the $0-implementation would still rule out 0 as a value for $0, so that the test from above will keep working.
Ciao
Frank Barknecht _ ______footils.org_ __goto10.org__
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Hallo, Miller Puckette hat gesagt: // Miller Puckette wrote:
That's funny... the reason $0 starts at 1000 and not 0 is because in Max the $ variables were printffed into the boxes themselves and I wanted to keep all the $ variables (at least the first 8999 of them) to the same width as a character string.
Ha, then I'm lucky. ;)
Of course probably the actual problem is, that it's hard to check if a certain argument was passed or not using plain Pd. The [select 0]-idiom is just a workaround here. (But as usual with workarounds: they work most of the time.)
Frank Barknecht _ ______footils.org_ __goto10.org__
In a kind of related question, I was wondering whether it would be
possible to get the next $0 number from Pd using a message, i.e. the
number that the next object to be instantiated will be assigned. I
wanted to script something that sent messages to a bunch of patches
that were dynamically created and I found myself wanting that number.
This also gives rise to the question of whether objects or messages
are the most appropriate for this kind of thing. I think mostly Pd
uses objects right now, like [samplerate~], [block~], etc. Perhaps
an object would be more appropriate since it would have an outlet to
report that number on.
.hc
On Aug 13, 2006, at 1:10 PM, Miller Puckette wrote:
That's funny... the reason $0 starts at 1000 and not 0 is because in Max the $ variables were printffed into the boxes themselves and I wanted to keep all the $ variables (at least the first 8999 of them) to the same width as a character string.
Anyway, $0 uses true integers, so that it's unlikely they will ever
reach zero (you'd have to fill your address speace 100s of times)... so I
think you're safe.cheers Miller On Sun, Aug 13, 2006 at 10:04:02AM +0200, Frank Barknecht wrote:
Hi,
I would like to check, if $0 was passed as an argument to an abstraction. The usual idiom is:
[loadbang] | [f $1] assuming, $0 was passed as $1 | [select 0] | this is $0 now
Now of course this fails, if $0 also can be zero itself. I know, that currently this is very unlikely, because $0 starts at 1000 and grows. But it would be great if possible future changes to the $0-implementation would still rule out 0 as a value for $0, so that the test from above will keep working.
Ciao
Frank Barknecht _ ______footils.org_ __goto10.org__
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/ listinfo/pd-list
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/ listinfo/pd-list
On Sun, 13 Aug 2006, Miller Puckette wrote:
Anyway, $0 uses true integers, so that it's unlikely they will ever reach zero (you'd have to fill your address speace 100s of times)... so I think you're safe.
Not quite. It breaks after 16776217 object creations. 16776217 = (1<<24)-1000+1.
Your "true integer" has a maximum value of (1<<31)-1, because the return value of canvas_getdollarzero is "int".
But then it gets converted to a 32-bit float (A_FLOAT) by canvas_realizedollar, and the maximum contiguous integer value of 32-bit floats is 1<<24 = 16777216 (if you increment it, it may stick there or increment by 2 instead, because there are no odd numbers beyond that point).
You don't have to fill your address space even once to get there, if abstraction instances get dynamically created and deleted over a long period of time.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju | Freelance Digital Arts Engineer, Montréal QC Canada
Oops.
cheers M
On Sun, Aug 13, 2006 at 10:15:20PM -0400, Mathieu Bouchard wrote:
On Sun, 13 Aug 2006, Miller Puckette wrote:
Anyway, $0 uses true integers, so that it's unlikely they will ever reach zero (you'd have to fill your address speace 100s of times)... so I think you're safe.
Not quite. It breaks after 16776217 object creations. 16776217 = (1<<24)-1000+1.
Your "true integer" has a maximum value of (1<<31)-1, because the return value of canvas_getdollarzero is "int".
But then it gets converted to a 32-bit float (A_FLOAT) by canvas_realizedollar, and the maximum contiguous integer value of 32-bit floats is 1<<24 = 16777216 (if you increment it, it may stick there or increment by 2 instead, because there are no odd numbers beyond that point).
You don't have to fill your address space even once to get there, if abstraction instances get dynamically created and deleted over a long period of time.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - t?l:+1.514.383.3801 - http://artengine.ca/matju | Freelance Digital Arts Engineer, Montr?al QC Canada