lambda
lambda copied to clipboard
`new`
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.
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.
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'}
e9392f8883ca275b7957dcb935d074c920e12855 introduces new
, but only for Lambda closures.