Bart Lateur wrote:
> 
> >Currently, attempting to use objects in a string context
> >yields garbage:
> >
> >   print "r is $r->func";     # "OBJ=HASH(0xef958)->func"
> >   print "r is ", $r->func;   # works, but clumsy
> 
> Does this expand to regexes?
> 
>         /$foo->blah/
> 
> To be consequent, it should. 

Yes, it would. This is already currently done with $hash->{ref}'s and
$array->[ref]'s in qq// strings, so why not $obj->ref's?
 
> Why interpolate "$obj->method" and not "Class->method"?

This is a decent point worth considering. 

I think another way to look at it which is more accurrate is that -> is
special in many cases already:

   /$foo->{blah}/       # -> special
   /$foo->[blah]/       # -> special
   /$foo->blah/         # not special?

In fact, I would argue this last one not working is quite surprising.
Why not simply make -> always special, and have you \escape it if you
want to use it explicitly?

   /$foo->blah/         # -> special, calls blah
   /Class->blah/        # ditto
   /$foo\->blah/        # escaped, not special

Besides, how often do you have to match "->" explicitly? I can't
remember ever having to. I think the line is more correctly drawn as "->
is always special". And you already have to use \-> for hashrefs and
arrayrefs, so this is nothing new.

> I don't like it, because so far, "-" nor ">" are metacharacters.

They still don't have to be individually, but taken together as -> they
are already special with hashrefs and arrayrefs, so extending this to
objects is quite natural.

> What I would like, is something equivalent to the "@{[...]}" hack

Brainstorming:

    print "Hello !{$r->foo}";
    print "Hello ![$r->foo]";

But I still think that making -> special in all situations is the more
consistent and flexible approach.

-Nate

Reply via email to