A few questions and suggestions.

Thiago Silva tsilva at sourcecraft.info
Mon Apr 30 10:15:27 PDT 2007

On 4/30/07, Brendan Eich <brendan at mozilla.org> wrote:
> > The correct syntax is in today's SpiderMonkey implementation already,
> > and it goes like this:
> > try {...}
> > catch (e if e instanceof TypeError) { ... }
> [...]
> ES4 has catch (e : type) ... clauses, as Thiago wants.
> /be

Yes, as Brendan said, I found this at

By the way, I forgot to CC to this list a reply I sent to Brendan. So,
I'm pasting it below (with minor corrections):


Hello Brendan,

On 4/27/07, Brendan Eich <brendan at mozilla.org> wrote:
> Did you read through http://developer.mozilla.org/es4/ ?

At the time I wrote the email, I just looked around it. Now, I belive
I read most of it. Looking more carefully, I found answers for 2
questions mentioned in my previous email:

I think catchalls are pretty much what I was looking for when it comes
to have something similar to Ruby's method_missing. Also, reading the
tc39-tg1-2006-001.pdf answered my question about the exceptions (being
able to specify exception types in the catch()). Thanks for the info.

Some of the questions remains, and a few more came to my mind. Here
are my (updated) notes:

*** toSource()

I have found the "source" property for function objects in:

Knowing that such feature is agreed for the spec, I have two questions about it:

a) Currently, firefox returns "{[native code]}" for native function
bodies when using toSource(). AFAIK the meaning of the "source"
property is to return the actual source of the function. Even if
native bodies can't be returned, I think it's awkward to return a
string that is not syntax valid:

eval(eval.toSource()); //syntax error!

Is it appropriate to specify that native functions should return
syntax valid code (in this case, a comment "/* native code */" could
be used, instead)?

b) As I mentioned before, how about making comments part of the
source? I like to think that the comment is part of the source as well
;) and, as I explained in my previous email, it would be great for
programming UIs (things like Squeak's Class Browser, for example).

function f() {
  //say hello
print(f.source) //the comment "//say hello" is part of the string
returned since it is part of the f's body

*** Access control

It is of my understanding that access control will be implemented
using namespaces, as explained in:

So I ask: What about being able to define a namespace for an object's
property without using the class declaration?  What I'm really looking
for is a way to define access control without being forced to use the
new class declaration. For instance, something equivalent to:

private o.foo = "bar" //property "foo" is defined as private

*** include directive

I assume the include directive is also an accepted feature:

Reading it, I came up with two questions:

a) What happens if the file specified can't be read?
b) What happens if the file included has syntax errors?

Personally, I would hope both situations to throw a catchable exception.

Thanks again,
Thiago Silva,
mailto: tsilva at sourcecraft.info
jabber: tsilva at jabber.org

More information about the Es4-discuss mailing list