I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2008-03-08 22:12:09-08 by cowanbill
Suggestion to Implement Strict Constructor?
I misspelled an argument name (e.g. 'last_nane' below) and spent time trying to find the cause. The argument name that I used was misspelled and silently ignored. I know my error, but I would hope for more help. It seems like different class builder modules have 'non-strict' constructor and other modules have 'strict' constructor to catch the misspelled names.

I did some research (i.e. pre-init, :init methods), but did not find any way to implement a strict constructor for those applications need this feature.
Do anyone have a suggestions?
#----------- Sample code for this situation -------------- use strict; use warnings; package My_Class; { use Object::InsideOut; my @first_name :Field :Default('Tom') :Std_All(first_name); my @last_name :Field :Default('SirDefault') :Std_All('last_name'); } #-- end of package scope. package main; my $obj = My_Class->new( first_name => 'Larry', #### last_name => 'Smith', last_nane => 'Smith', #-- Incorrect spelling ... ); print "1. Object field 'first_name' is: ", $obj->get_first_name(), "\n"; print "1. Object field 'last_name' is: ", $obj->get_last_name(), "\n"; print "\n**** Normal Exit **** \n"; exit;
Direct Responses: 7314 | Write a response