develooper Front page | perl.perl6.language | Postings from October 2006

Re: Automatic coercion and context

Thread Previous | Thread Next
From:
Jonathan Lang
Date:
October 1, 2006 02:17
Subject:
Re: Automatic coercion and context
Message ID:
ef30550b0610010217o394c447eu38cc3a65f8152735@mail.gmail.com
Jonathan Scott Duff wrote:
> I hope you're way off the mark. Automatic coercion was one of the
> annoyances I remember from C++. Debugging becomes more difficult when
> you have to not only chase down things that are a Foo, but anything
> you've compiled that might know how to turn itself into a Foo.

OTOH, there is a time and place for so-called "automatic" coercion,
such as the way that perl freely converts between Str and Num.
Indeed, ISTR something about standardized stringifying and numifying
method names that let _any_ object turn into a string or number (or
boolean, IIRC) when placed in the appropriate context.  And I can see
some benefit to extending this ability to other types, as long as it's
used sparingly.  In particular, I'm thinking about complex numbers -
it would be nice to see perl convert between the rectilinear and polar
representations of complex numbers in the same way that it converts
between Num and Str.

-- 
Jonathan "Dataweaver" Lang

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