The stupid question is the question not asked | |
PerlMonks |
Re: Getting rid of "new", Implied actions are badby cerelib (Novice) |
on Jul 07, 2006 at 21:41 UTC ( [id://559870]=note: print w/replies, xml ) | Need Help?? |
The "new" convention seems logical and the same goes for "spawn" or "create". The problem with your idea is that it lacks a verb. I will grant you that "new" it not an English verb, but it is a Perl verb. Without a verb, your statement "Some::Other::Class( \%options )" has no visible action although one is being performed. For that reason alone it goes against many design decisions of Perl itself. In Perl there are visual cues to help you understand what you are seeing. A scalar looks like a scalar '$', an array looks like an array '@', and so on. To this extent an action looks like an action in the direct form 'Class->new', the indirect 'new Class', or with the implied subject 'new' (this is the most deceptive of the three). That last one may look like it justifies your idea, but what you want is an explicit subject with an implied action. So, I think the implied constructor is a bad decision. It will lead to more confusing code. If you really hate "new", get with the people responsible for Class::Struct and talk to them about changing naming conventions.
In Section
Meditations
|
|