From: Matt Kruse on
On May 12, 8:52 am, Scott Sauyet <scott.sau...(a)gmail.com> wrote:
> Right, that is fairly obscure.  But Thomas gave an example that is
> quite realistic:
> | <form>...<input name="foo[]">...</form>
> A number of server-side environments might generate something like
> that.

As I responded to him, the code in its current form works fine in this
case, or any case where a property has "[]" in it's name. It just
fails if the property has "[\d+]" in its name. I realize this also
happens in cases like:
<input name="person[0].phone">
which can be generated from frameworks like Struts, for example.

It's a limitation, certainly.

But IMO, a limitation does not necessarily mean a bad API or useless
function. It's pro/con.

If you can solve 99% of cases with straight-forward code which fails
on the remaining 1%, then I think it would be a mistake to through
that out just because you can't solve the most general case. That kind
of thinking leads to being less productive and insanity ;) But on the
flip side, I do think it's good to be as generalized as practical, and
that's exactly why I threw it out here. To get feedback and to point
out cons that I hadn't considered. For that, it has been useful
already.

Matt Kruse
From: Scott Sauyet on
Matt Kruse <m...(a)thekrusefamily.com> wrote:
> I could modify it to take any number of arguments, to support both
> ways of accessing the properties - either as a single string with no .
> in it, or as multiple strings with no limitations.

I would suggest you don't. Make your API as clean as possible while
still meeting your requirements and then live with whatever
restrictions that entails. Of all the critiques of jQuery I've seen
here, by far the most compelling is against the re-use of "$" to mean
so many different things.

--
Scott
From: Garrett Smith on
Asen Bozhilov wrote:
> Garrett Smith wrote:
>> Asen Bozhilov wrote:
>
>>> Of course that is not solve the design problems. I will prefer to use
>>> array which contain each property name. For example:
>>> deep(context, ['property1', 'property2', 'propertyN']);
>> Does deep check own or prototype?
>
> The meaning of _deep_ here is not related with prototype chain.

Obviously.

The
> deep here is used as deep level of property accessing instead. But if
> I should implement that method I will use square bracket notation for
> each property and that will lookup in prototype chain. I do not see
> any reasons to handle only own properties.
>
Makes sense.
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
From: Thomas 'PointedEars' Lahn on
Matt Kruse wrote:

> Thomas 'PointedEars' Lahn wrote:
>> No, by contrast you will not be able to handle property names that
>> contain `|'.
>
> Umm, then you just pick a different delimiter that doesn't conflict
> with your property names. Duh.

Your shortsightedness blinds you again for the possibilities that await you.
As long as you choose string delimiters for separating parts of the
/MemberExpression/ used to access a property, your implementation will not
be able to deal with objects that have properties with names that contain
those delimiters.


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
From: Matt Kruse on
On May 12, 11:32 am, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
wrote:
> Your shortsightedness blinds you again for the possibilities that await you.  
> As long as you choose string delimiters for separating parts of the
> /MemberExpression/ used to access a property, your implementation will not
> be able to deal with objects that have properties with names that contain
> those delimiters.

Thank you, Captain Obvious!

Be careful with these astounding leaps of logic. Soon you'll be making
conjectures like "The round ball is round". Sweet hot damn! Genius! :)

Matt "the key to picking a good delimiter is to use one that is not
contained in your string expression" Kruse