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.

Reply via email to