On Mon, 7 Aug 2000 05:41:10 +1000 (EST), Damian Conway wrote:
> > > $scalar = date; # scalar ctime date, same as current
> > > $object = date; # object with accessor functions (new)
> >
> > How are these distinguished?
>
>If $object is typed (my Date $object), then want() will be able to detect the
>difference.
Yuck. So if $scalar is not specified as an object, but just a scalar
(e.g. a hash element), then I get nothing but a string? Triple Yuck.
We HAVE a mechanism to do this already. It's usually called "stringify":
overload the '""' function for the object class. Then:
$scalar = "" . date;
or
$obj = date;
$scalar = "$obj";
or
print scalar date;
Returning an object is the most generally useful. Converting it to a
string on the fly when you need a string, works best for me.
--
Bart.
- Re: RFC 48 (v1) Replace localtime() and gmtim... Bart Lateur
- Re: RFC 48 (v1) Replace localtime() and gmtime() ... Gisle Aas
- Re: RFC 48 (v1) Replace localtime() and gmtim... Bryan C . Warnock
- Re: RFC 48 (v1) Replace localtime() and gmtim... Nathan Wiger
- Re: RFC 48 (v1) Replace localtime() and gmtime() with ... Russ Allbery
- Re: RFC 48 (v1) Replace localtime() and gmtime() ... Jonathan Scott Duff
- Re: RFC 48 (v1) Replace localtime() and gmtime() ... Jarkko Hietaniemi
- Re: RFC 48 (v1) Replace localtime() and gmtime() with ... Damian Conway
- Re: RFC 48 (v1) Replace localtime() and gmtime() ... Nathan Wiger
- Re: RFC 48 (v1) Replace localtime() and gmtime() ... Bart Lateur
- Re: RFC 48 (v1) Replace localtime() and gmtim... Nathan Wiger
- Re: RFC 48 (v1) Replace localtime() and gmtime() with ... John Tobey
