develooper Front page | perl.perl5.porters | Postings from December 2007

Re: "strict refs" not strict enough

Thread Previous
From:
Aristotle Pagaltzis
Date:
December 28, 2007 01:44
Subject:
Re: "strict refs" not strict enough
Message ID:
20071228094354.GG564@klangraum
Hi Mark,

it’s a good argument and I agree. I want to nitpick just one
point, though:

* Mark Jason Dominus <mjd@plover.com> [2007-12-28 09:10]:
> But it solves it in a kind of stupid way.

I don’t find it stupid; au contraire, I find it quite useful.
It’s no harder to pass any other non-reference value into
something that expects a reference than it is to pass a
stringified reference. Indeed I find that when the `refs`
stricture traps a mistake I made, it is almost invariably

    Can't use string (...) as a HASH ref [...]

because I got the construction of a complex data structure wrong
(which, as an aside, is where inferred structural typing à la
Haskell shines brightly). I almost never see any other soft-ref
exception. (Well, besides attempting to call a method on `undef`,
but presumably that could be trapped in other ways.)

So I agree that it would be worthwhile to forbid implicit ref-to-
string coercions in order to trap such errors where they actually
happen, but I find that the current behaviour is *also* useful on
its own merits.

-- 
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1}
&Just->another->Perl->hack;
#Aristotle Pagaltzis // <http://plasmasturm.org/>

Thread Previous


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