On 9/25/05, Yuval Kogman <[EMAIL PROTECTED]> wrote:
> On Sun, Sep 25, 2005 at 12:52:08 +0200, Juerd wrote:
> > Damian Conway skribis 2005-09-24  8:31 (+1000):
> > > >In my opinion, making the string value in interpolation different from
> > > >the value in Str context is madness.
> > > It's dwimmery.
> >
> > It's dwymmery, or dwdmmery indeed. Not at all what I mean, am likely to
> > mean, or will ever mean.
> >
> > > Which often looks like madness until you realize that it's just a
> > > reflection of how most hackers think. ;-)
> >
> > This calls for a poll, because I believe nothing of this "most".
> >
> > Hackers on this list, what do you think?
>
> [...snip...]
>
> On top of that there is the fact that perl 5 people come to expect
> that ("$foo") means ("".$foo), except that the first version is
> easier to read.

Yes, that's how I explain it to anyone who really needs to know, which
is usually to someone asking about overloading.

However, I see a useful difference between Str[ingification] and 'does
Interpolate' or whatever that role might be. However, the names might
want to change to protect the innocent.

The Stringification of a UnixEpochTimestamp should probably be the
same as its Integerization -- 12345678900. However, the Interpolation
of it should be the locale-specific POSIX-style datetime string.

Here's how I would do it if $Ashley == any(@Larry)

The .as(Str) of an object would be its serialization -- what you would
spit out for the Perl6 version of pickle/Storable/whatnot. Ideally,
the Str representation would be lossless, informationally, so you
could call the deserialize/unpickle (.from?) method using its
return-value:

my Thingy $foo .=from($thing);

The Interpolate role's method would return the pretty-printed,
possibly LOSSY presentation of the object's information.

For example:

my $color = new HTML::Color("magenta");
if $color.as(Str) eq '#FF00FF' and "$color" eq "magenta" {
  $Ashley++;
}

So, to summarize, I want .as(Str) to be the lossless canonical
representation, as well as the basis for the default .hash method,
while Interpolate would be the pretty-printed localized lossy
presentation Role.

Ashley Winters

Reply via email to