- From: liorean <liorean@gmail.com>
- Date: Tue, 6 Jun 2006 03:16:54 +0200
- To: "Web APIs WG (public)" <public-webapi@w3.org>
> On Mon, 05 Jun 2006 19:49:36 +1000, Anne van Kesteren <annevk@opera.com> > wrote: > > I'm not really fond of matchOne()... Is there any precedence on this? Not in JavaScript that I can think of. The only precedent case I can think of for this example is String.prototype.match. That function does both though; it's the "global" flag on the regex that determines whether to return just the first match or all of them. And in my mind, that is a design error in regex in JavaScript, since it's entirely plausible to want to use the same regex in both types of matches. This can be done by setting the global flag on the regex and using RegExp.prototype.exec when a single match is desired and String.prototype.match when an array of matches is wanted Just the fact you have to change whether it's the regex or the string that you call a method on - not to speak of the fact you need to set the global flag on all regexes if you want this behaviour uniformly - makes this an ugly solution to my eyes. The responsibility for solving problems like this should lie on the functionality provider, not the functionality consumer. On 06/06/06, Charles McCathieNevile <chaals@opera.com> wrote: > There is a precedent for any naming thing you care to consider, and some > you would prefer not to. Indeed... I think my example highlights that. > I am with Jonas on this - I don't think the name hurts or increases > confusion and it does slightly decrease it. But picking names is always > painful. We'll never get it perfectly right, but we can always get it > oh-so-very wrong :( I tend to agree here. I don't like the suggested design of having selectors be second class though. I think selectors are important enough to have as first class objects, just like regex are. Compile them to an object once, use multiple times. Little is lost in performance for those using them once, but much is gained for those using them over and over. It makes the code for a single use a little more complex, but not that very much. It doesn't make much of a difference in code complexity for those using them multiple times, and might even mean a reduction in code complexity. It does make up the question of whether the methods for matching should be placed on the Selectors objects or the Document/Element nodes though. -- David "liorean" Andersson <uri:http://liorean.web-graphics.com/>
Received on Tuesday, 6 June 2006 01:17:05 UTC