Open Raynos opened 10 years ago
Personally I think banning constructor functions and this
is a good idea.
Banning new
is probably impossible because that's just how you create new binary data structures in javascript.
why not just support clone(Buffer)
and clone(Float64Array)
? we can just add some fanciness to the compiler to treat it differently for builtins.
@mikeal
I don't want to use a compiler to write javascript. I could import the fif-clone
module and it could support that use case I guess.
in order to inject standard methods, and enforce the language, it's going to have to run through a compiler. however, it could be as simple as $ fif program.fif
and that could default to compiling for node and running it.
I agree that
new
andthis
is really complicated.However for reasons of performance and for compatibility with host environments we might want to keep
new
.For example
new Buffer()
ornew Float64Array()
Either we decide that all constructors are part of the standard library and you dont get to create your own constructors so we can get rid of
this
completely.Or we limit the usage of
this
and allow people to write their own constructors.We could have a limited constructor that looks like
The only usage of
this
that is valid is inside a constructor function. The only thing valid to do is to assign properties tothis.x = prop
.This has the advantage of working with the rigid shape optimizations build into todays javascript.