I believe constructors are a special case that, if not promoted to being a keyword, should be close in precedence to keyword in terms of compile-time parsing. Regardless of the Perl5 doc misnomer of "indirect object," which we call more correctly "dative" for builtins like print() and tie(), the constructor in OOP is not the same as a dative and is more like this, to me:
I am advocating for "what makes the most sense to a 'native' speaker/programmer" in the case of the constructor being NOT an indirect object but like the way both French and English says "nouveau riche" in the same way. This is what the French might call the English people (and later the Americans) during the Industrial Revolution. If you do what Wikipedia does and transliterate this, you would say "new rich" meaning new is an adjective qualifying the noun rich. Almost all of the time in other Romance languages besides English, the adjective goes after the noun ("mi camisa negro"). I believe a named constructor should behave like the way a *native* English speaker would translate this phrase, the more correct form as "newly rich" and not "new rich," maintaining that the qualifier goes before the noun. The point of the "indirect object syntax," which is a misnomer, in the case of constructors is a native speaker does not translate the phrase "nouveau riche" back into English. The phrase is well understood as-is in English. Thus, the constructor is not like any other method and, as someone has already pointed out, in this case we explicitly mean that the object does not call itself.
You could have new, spawn, clone, gimmea, nextlike, &c. be explicit constructors and not subclassed or such. I am just saying the idea of this type of syntax is to raise our sophistication in the language, meaning we don't want people to "translate back" something for which we actually do want to be well understood in context syntactically, semantically, and overall grammatically. | [reply] |
| [reply] |
I believe constructors should be treated as a special case. Even though somewhere it says bless/ed is the only real constructor in Perl6 (it seems that way in Perl5 as well) for what we mean, for someone who wants a "shazam automagic gimme this object," the notion of a "free new" in this type of adjectival sort of syntax is what the typical object-oriented programmer expects. That Perl6 has currently settled upon using the colon is still too ugly and is as fastidious and ridiculous as saying 'CGI'::->new() in Perl5. Syntax should help elevate comprehension without making things *look* ugly, and I will try to advocate that when we mean an object we should type-treat it like one, which is exactly what the verb bless() does.
| [reply] |