ES4 draft: Function

Jon Zeppieri jaz at bu.edu
Tue Mar 11 10:24:49 PDT 2008


I promise not to drag out this discussion, since no one else seems to
be interested in it.

On Tue, Mar 11, 2008 at 12:16 PM, Lars Hansen <lhansen at adobe.com> wrote:
>
>  Sure, nobody argues about that per se, but I don't see the spec
>  as being the place to take an ideological stand about whether
>  global.eval is cleaner than 'new Function', if taking a stand
>  doesn't gain practical implementations anything at all.

I'm not trying to make an ideological stand -- or, at least, not a
particularly controversial one.  I put far too much stress on syntax
in my last message.  The more important objection to 'new Function'
concerns its semantics.  The Function constructor has an awkward
status in the language. Most objects are constructed by calling a
constructor or by using a literal syntax, the semantics of which can
be specified in terms of constructor call + accessor calls.  E.g.:

    [a, b] has the same semantics as
    let (t = new Array()) (t[0] = a, t[1] = b, t)

...whereas you cannot, in the general case, *locally* rewrite a
function expression in terms of 'new Function.'  Also, there's the
point I did raise in my last message: while you can subclass function,
there doesn't appear to be much point in actually doing so --
precisely because most function construction does not go through the
Function constructor.


> The reality
>  is that 'new Function' and 'arguments' are available in all
>  implementations, they are in wide-spread use, and their use will
>  be propagated as long as implementations support them.  Maybe if
>  they are deprecated in the spec their use will see some
>  decline; maybe ditto if better, alternative features are added
>  to the language.  I have more faith in the latter than in the
>  former.

These options aren't mutually exclusive, and I don't see the harm in
deprecating this stuff.  Now, if someone will offer a defense of 'new
Function,' that's a different story.  I am not trying to be
controversial here.

>
>  I don't really care about 'new Function' as it's just another
>  API to functionality that will exist anyway, and 'new Function' is
>  comparatively clean -- I don't agree that it is significantly less
>  sane than global.eval.  But I and others do care about 'arguments',
>  so we have rest arguments and 'this function'; we do care about the
>  operator form of 'eval', so there's been some discussion about
>  whether to simply outlaw its use inside classes.  These are better
>  ways to make progress than paper deprecation, IMO.

No question that 'arguments' is a more important issue.

-Jon


>
>  --lars
>
>
> _______________________________________________
>  Es4-discuss mailing list
>  Es4-discuss at mozilla.org
>  https://mail.mozilla.org/listinfo/es4-discuss
>
>



More information about the Es4-discuss mailing list