Hi Christopher
Thanks, arh it seems I get nervous when posting to the list. I didn't
pull that from code, I just made it up on the spot and, true, it's
erroneous.
What I usually use is probably closer to:
meta_data [i][j] = new Object();
_in = meta_data [i][j] // A tidier way to get to it's items. So then:
_in.alpha = startValue;
_in.delta = distance;
Thanks for the link. I've been think to writ my own recursive copy
object function but a discussion on kineme.net led me to draw the
false conclusion JS doesn't do recursion. Obviously wrong! I guess
someone was saying it can't do infinite recursion and return the
'limit' of the function. You logObj function was a nice demo of
recursion too! Both in one day ;-)
Best
Alastair
On 27/02/2011, at 2:19 AM, Christopher Wright wrote:
Would _in be a pointer to Input[i] or a structure in it's own right?
It's a pointer to the original object. If it's a number, you get a
copy, anything else you get a pointer to the original (I think?
It's been ages since I've poked at this detail).
_in and Input[i] (which are the same thing) are JS objects. More
specifically, they're structures (you're passing in a structure of
structures).
Typically I use
_in = meta_data [i][j] // A tidier way to get to it's items. So
then:
_in = new Object();
_in.alpha = startValue;
_in.delta = distance;
Then I expect to find the values I assigned in meta_data object.
why would you expect that? you're redefining the object on the
second line (_in = new Object() literally means "I no longer care
what _in held. I don't care about its hopes, its dreams, its
current values, or anything. if I've got the last reference to it,
you can even garbage collect it for all I care. I now want _in to
be a completely new object, totally separate and unrelated to its
current state").
This is exactly equivalent to erroneously expecting the following:
x = 42;
x = 21; // new Object()-esq.
x += 2; // I expect X to equal 44 because it was 42 once?
Is there a sure way to know when I'm making a pointer variable and
when I'm copying a value. Obviously structures can't be assigned
with just a = my_struct so I'm going to get a pointer in those
cases but what if I'm not sure what's in my_struct.Is there a way
to test to see a variable is a pointer or not?
use a recursive descent clone function:
http://my.opera.com/GreyWyvern/blog/show.dml/1725165
--
Christopher Wright
christopher_wri...@apple.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list (Quartzcomposer-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com