play-co/js.io

The constructor should not be called "init".

Closed this issue · 2 comments

mcav commented

js.io should use a different name for the overridden constructor. It is a relatively common singleton pattern to have the function that initializes the singleton called "init".

Though not JavaScript, both python and objective-C use "init" for constructors.

Mootools uses "initialize"

C++ style languages use the name of the class as the constructor. We could do this, but it would probably require either more preprocessing or runtime-trickery.

construct (PHP, right?)

What other options are there?

mcav commented

Python uses __ init __, which is very different than "init". Objective C is perhaps one example where it's idiomatic to initialize a singleton with "initialize"... I'll go ahead and pivot a little bit here and acknowledge that while "init" isn't ideal, it's probably good enough.