develooper Front page | perl.perl5.porters | Postings from October 2003

Re: [PATCH] Re: [PATCH pod/perlfunc.pod] ref can return false on references

Thread Previous | Thread Next
From:
Casey West
Date:
October 6, 2003 13:55
Subject:
Re: [PATCH] Re: [PATCH pod/perlfunc.pod] ref can return false on references
Message ID:
20031006210021.GC58957@geeknest.com
It was Monday, October 06, 2003 when Gisle Aas took the soap box, saying:
: I've noticed that the documentation of bless already says "Make sure
: that CLASSNAME is a true value" and have said that for a long time.  I
: think we could simply enforce that and disallow all of these:
: 
:    bless $thing, 0
:    bless $thing, "";
:    bless $thing, undef;

As a side note, it's difficult to have a useful class (package) name
that is a numeral anyway.

  [cwest@casey cwest]$ perl -e'package 0'
  syntax error at -e line 1, near "package 0"
  Execution of -e aborted due to compilation errors.
  [cwest@casey cwest]$ perl -e'package 1'
  syntax error at -e line 1, near "package 1"
  Execution of -e aborted due to compilation errors.
  [cwest@casey cwest]$ perl -e'package 100'
  syntax error at -e line 1, near "package 100"
  Execution of -e aborted due to compilation errors.

Of course, the documentation does state that namespaces shouldn't
begin with a digit.

  [cwest@casey cwest]$ perl -e'package 100a'
  syntax error at -e line 1, near "package 100"
  Execution of -e aborted due to compilation errors.

Perl becomes even more upset when you try and circumvent further.

  [cwest@casey cwest]$ perl -e'sub 100::foo { "hi" }'
  Illegal declaration of anonymous subroutine at -e line 1.

Then, of course, there are the jokers.

  [cwest@casey cwest]$ perl -le'sub UNIVERSAL::foo { "hi" } print +(bless [],0)->foo'
  hi

I guess my point is, Perl has had this restriction in many forms,
moving it along to bless() would not be a problem in my mind.

  Casey West

-- 
Shooting yourself fin the foot with Algol
You shoot yourself in the foot with a musket. The musket is
aesthetically fascinating, and the wound baffles the adolescent medic
in the emergency room.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About