is ES4 getting too bloated?

Garrett Smith dhtmlkitchen at gmail.com
Sun Oct 21 21:31:43 PDT 2007


(fwd to list - I clicked the wrong button again...)

On 10/21/07, Brendan Eich <brendan at mozilla.org> wrote:
> I know of two industry-scale implementations under way, in addition
> to Mozilla's Tamarin project, and Michael O'Brien (mbedthis.com), all
> implementing ES4 in the next six to nine months. There's no reason,
> zero, apart from will to do something else, why Microsoft (which has
> enormous resources, in expert people and money) couldn't do likewise.
> Perhaps they yet will -- we don't really know what's coming in IE8 yet.
>
> Give the overview at http://www.ecmascript.org/es4/spec/overview.pdf
> a read and let us know what you think.
>
"RegExp objects can be called as functions (equivalent to invoking
their exec method)..."

Example:
/foo/('foo')

What is the purpose? To save five characters? e,g, ".exec"

I don't see how it fulfills a use case. It would seem to make code
more hot-doggable, and potentially confusing (less explicit)

function bork( a ) {
  if( a( "foo" ) ) {

 }
}

Doesn't it look like "a" is a function? Well, maybe in ES4, it's a RegExp.

If I were the code reviewer on that, I would ask the person to use
.exec. Why? Because it's confusing. Not everyone will expect that.

Come refactoring time, the next guy who looks at the code will have to
familiarize himself right away. He might not be a JavaScript expert
whose keen on the latest features. Maybe he's a Backend guy.

Contrast to that:

function mork( a ) {
  if( a.exec( "foo" ) ) { // Ah, a looks like a RegExp.

 }
}

How is this feature, callable regexps, justified? Why not just let
programmers use .exec?

I say:
It's not necessary, it makes the code less explicit. YAGNI!


Garrett

> /be
>


--
Programming is a collaborative art.


-- 
Programming is a collaborative art.



More information about the Es4-discuss mailing list