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-04 19:58:55-08 by cowanbill
Should GET-only accessor give an error message if given a parameter?
I defined a GET accessor (":Get(first_name)" below) and I then used that accessor with a parameter value. The "first_name" accessor retrieved the old field value and quietly ignored the parameter value, '*** SetValue ***'. No error message was given! This happened with OIO version 3.38, Perl 5.8.8 on Windows.
What is the correct behavior if GET-ONLY accessor are given parameter values?
Thanks, Bill
use strict; use warnings; package My_Class; { use Object::InsideOut ; my @first_name :Field :Arg(first_name) :Get(first_name) #-- Only define a getter, no setter! :Default('***Default***') ; } #-- end of package scope. package main; my $obj = My_Class->new(first_name => 'Larry'); #-- Note that this SET OPERATION does not give error. #-- The SET value is silently ignored! print "1. Object field is: ", $obj->first_name('*** SetValue ***'), "\n"; print "2. Object field is: ", $obj->first_name(), "\n"; print "**** Normal Exit **** \n"; exit; The output is: 1. Object field is: Larry 2. Object field is: Larry **** Normal Exit ****
.
Direct Responses: 7269 | Write a response