From: nick on
On Jan 23, 2:54 pm, Asen Bozhilov <asen.bozhi...(a)gmail.com> wrote:
> nick wrote:
> > Thanks for your response. Not sure I understand what you mean here,
....
> for (var i = p.length; p--;)

You're right, of course, I forgot iterating over arrays with for...in
is a no-no. I changed my code to use a normal in loop after you
mentioned it previously (identical to the example you wrote here
actually), but still was not sure if that was what you were referring
to. Thanks for clarifying. :)

> Yes, my mistake. I did see overriding `set'. However, i still miss
> general idea. Why do you want this? If you want explicit pointers you
> can write in some low level language like `C`.

Well, don't forget many higher-level OO languages use pointers /
references too... C++, PHP, the .NET stuff, etc. In fact with PHP,
since objects are already passed by value, explicit references are
most commonly used for primitive datatypes (although variables/
parameters that are explicit references to objects do act slightly
differently from normal variables assigned to objects, so they could
technically have some use).

As for your question, I don't really have a good answer. It was just a
learning experiment; I wanted to see if it was possible without too
much hackery or overhead. I assume it could be used for things like
output variables, which might come in handy if you needed to add some
'return values' to something with a fixed API... imagine a method
returns an int, and other code relies on that behavior, but now you
also what the method to give a text description when it runs if the
script is in "verbose mode," say... output variables might come in
handy here?

I don't know, I guess I haven't really thought it through, it just
seems like something that might be useful at some point. I'll be sure
to make a followup post if I actually come up with a good use for
it. ;)

-- Nick
First  |  Prev  | 
Pages: 1 2
Prev: jQuery vs. My Library
Next: try catch catches when