lambda icon indicating copy to clipboard operation
lambda copied to clipboard

`new`

Open 71104 opened this issue 9 years ago • 3 comments

Provided as a global utility function (it will not become a keyword, it can be overridden by defining variables and parameters with the same name).

The use case is creating instances of objects provided by the native environment, e.g.:

new Error "something went wrong"

Or:

new Date 1440342320000

Note that associativity is left-most, i.e.:

(new Date) 1440342320000

The number of arguments that still need to be applied before returning the new instance is determined by the length of the constructor.

71104 avatar Aug 23 '15 15:08 71104

After 7bf96132b458d735df13bc1da4469015cd1a0d18 all the global constructors have this as the first parameter, so this is no longer an option. new should be implemented before the next release. I'm also marking this a bug.

71104 avatar Jun 17 '16 18:06 71104

Based on the new unmarshalling algorithm for native closures, the number of parameters to apply is no longer determined from the length of the native closure.

For native constructors new should work like this:

new Date {1440342320000}

Note that this is not specified because it's bound by new. A global non-constructor function would still need an explicit this:

alert window {'hello'}

71104 avatar Sep 03 '16 14:09 71104

e9392f8883ca275b7957dcb935d074c920e12855 introduces new, but only for Lambda closures.

71104 avatar Sep 22 '16 14:09 71104