note
salva
bless attaches a method dispatch table to some Perl data structure. That's not what most people would consider a constructor.
<p>In most programming languages the constructor is some function that gets called once the object has been allocated in memory in order to have its attributes initialized. Setting its method dispatching table is something done by the language runtime under the hood, not inside the constructor.
<p>Perl leaves to the programmer the task of allocating the object storage, setting the dispatch table and initializing the object for greater flexibility.
<p>In my opinion, a constructor in Perl can be any function or code fragment returning a new object in an usable state. For some simple cases, just a <c>bless {}, $class</c> can qualify as such, but the usual thing is to use a method for that and to call it "new".
957109
957152