On Sun, Sep 25, 2005 at 10:59:38 -0700, Ashley Winters wrote:

> 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.

Why? What value does the stringification of a date have as a
stringified integer? If we were to implement such semantics,
wouldn't it be wiser to print "The time in seconds since the epoch
is { +$time }"? That's much more readable, obvious and
nonsurprising, without being overly long or tedious.

I would never say something like

        "the time $time is " ~ $time ~ " seconds since the epoch"

That's simply absurd. Especially when the context of the string (the
stuff it's being interpolated to - not the programmatic context) is
not 100% self explanatory - then I would need to comment it.

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

You mean eqv.. =(

> The .as(Str) of an object would be its serialization

as is formatting, not serialization:

        $time.as('%d');

or something... I don't really know how this works

For serialization you have the .perl method, which is roughly the
same as Data::Dumper (code to be evaled), or some more heavy duty
package (i expect Storable to have a pretty consistent interface).

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

my Thingy $foo = eval($thing.perl);

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

Uhuh, which is a flawed concept, because whose to decide what should
be lost? why does the perl prelude have to decide what's valueable
and what can be lost during *stringification or interpolation* now,
when this language is supposed to live for another 20 years?

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

$color.hex_triplet; # no alpha
$color.name; # if we have one... or we can try to make one up (#ff0033 is 
bluish red ;-)

I see no reason why these two should behave in anyway, except that
one of them is the canonical format. There is no mnemonic device
whatsoever to link interpolation to color naming, and
stringification to hexadecimal representation.

Why isn't the str method "(255,0,255)"? Why isn't interpolation more
expressive and "Dwimmy"?

> 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.

For localization we need another thing. I propose a new prefix
operator, with some funny char we haven't used yet. It would be a
part of the Localizable role, and it would return a Str.

-- 
 ()  Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418  perl hacker &
 /\  kung foo master: /me supports the ASCII Ribbon Campaign: neeyah!!!

Attachment: pgp7tW0x35n8W.pgp
Description: PGP signature

Reply via email to