Function Constructors as a type?

Kris Zyp kriszyp at xucia.com
Tue Jun 26 14:24:54 PDT 2007


Thanks Brendan, appreciate the help.
Still curious though if anyone has an idea about how toJSONString should
operate on mixed namespace objects though... Perhaps toJSONString will just
use the identifier part of the name (leave out the namespace), and/or only
use the names that have open namespaces and leave it to JSON extensions to
attempt to serialize namespaces?
Kris


On 6/26/07, Brendan Eich <brendan at mozilla.org> wrote:
>
> Functions are objects (instances), not types. Any new F given function
> F(){} must return an Object, as in ES1-3.
>
> You can write function types of course, they are structural types:
>
>
> type F = function (int, double, string):Object;
>
>
> The usual subtyping rules apply, with sane extensions for optional and
> rest parameters. An update to spec/type_system.html is coming soon, and look
> for spec/type_relations.html too (under http://developer.mozilla.org/es4/
> ).
>
>
> /be
>
>
>   On Jun 26, 2007, at 1:51 PM, Kris Zyp wrote:
>
>  Is it possible to use a function constructor as a type? For example:
> function F() {}
> var f : F = new F;
> I assume this is not allowed, although I would think it would be nice if
> it were allowed, but I can't seem to find anywhere in the spec where this is
> explicitly stated and t he current reference implementation goes into an
> infinite loop when this is executing, I assume that is not the intended
> behavior :).
> Kris
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.mozilla.org/pipermail/es-discuss/attachments/20070626/971f6d76/attachment-0002.html 


More information about the Es4-discuss mailing list