ceifa / wasmoon

A real lua 5.4 VM with JS bindings made with webassembly
MIT License
449 stars 29 forks source link

Class.new(...args) vs Class.create(...args) #86

Open WebReflection opened 11 months ago

WebReflection commented 11 months ago

There's a lengthy discussion in TC39 around classes instantiations and I've realized wasmoon wraps these as arrow function which can't ever be used with new in general, but it also uses Class.create() instead of the more acknowledged and developer friendly (because it's backed by JS new syntax) Class.new(...args) pattern.

Beside the TC39 discussion though, it would be very community friendly if all interpreters with instantiation ability would follow a common pattern such as Class.new(...args) is, compared with .create(...) in wasmoon or pm.new(pm.Thing)(...args) in PythonMonkey.

As summary: please consider offering .new(...args) convention to instantiate JS objects within the wasmoon runtime, thank you!

ParadiseFallen commented 11 months ago

@WebReflection you can just fork it and provide samplels and actuall impl of it

WebReflection commented 11 months ago

I'm afraid I am going on vacation next couple of weeks and I have other issues to tackle internally (before that) ... but if this is the answer, I will eventually try to do what you suggested, although it will surely take a long while.

ParadiseFallen commented 11 months ago

@WebReflection im not a contributor and not an author. It seems that original wasmoon creator not contributing too much now. So if you want changes it seems much easier to just bringh it on your own (as i do).

WebReflection commented 11 months ago

@ParadiseFallen oh no, we clarified that aspect already https://github.com/ceifa/wasmoon/issues/85#issuecomment-1668591981

ParadiseFallen commented 11 months ago

@WebReflection fine