On Sat, 2002-05-11 at 17:43, Damian Conway wrote:
> Paul Johnson wrote:
> 
> > I've always found the word "like" to be very wishy-washy in a computer
> > langauge.  In what way is newbaz like baz?  And just how alike are they?
> > There must be a better way to describe this.
> 
> Perhaps:
> 
>       method set_baz($newbaz is compatible($.baz)) { $.baz = $newbaz }  
>       method set_baz($newbaz is typeof($.baz)) { $.baz = $newbaz }  

I don't like the second one, as it implies that Perl has types, which it
really doesn't (properties are just that, properties).

The first is a bit long, but I could get behind it in a crunch.

However, my first thought is, "why do we need a keyword here?"

Since it's not otherwise valid syntax (the semi-unofficial battle-cry of
perl6-language ;-), I propose:

    method set_baz($newbaz is $.baz) { .baz = $newbaz }

There's two ways to take C<$x is $y>. I think it's easy enough to get
people used to the idea that aliases are created vi C<:=>, so there's
really only one left.

And, yes I do think that using the auto-accessor is more correct. It
should be in-lined under most circumstances, but if someone comes along
later and moves that accessor into a super-class, we're still good.


Reply via email to