Rob Kinyon <[EMAIL PROTECTED]> writes:

> On 11/4/05, Michele Dondi <[EMAIL PROTECTED]> wrote:
>> I'm still convinced my remark _partly_ applies in the sense that the
>> overall impression is that a vast majority of most common needs is
>> addressed by a *subset* of the current features and trying to stuff all
>> them in has brought in quite a lot of discussions of which I'm not even
>> sure if they've all settled down.
>
> I think a good comparison can be made to Ruby. For work, I've been
> learning Ruby this past week (we're going to try out Rails to see if
> we like it). As my colleague put it, Ruby has all the P6 features we
> want and it's usable now.
>
> Ruby's OO system is 1000% more complex that Perl5's. Yet, it's still a
> net win. For one thing, I don't have to write the following anymore
> (lifted from a CPAN module I am working on):

The thing about Ruby (and Perl 6's) OO system is that the complexity is in the
right place -- tucked away where most people don't have to worry about it until
they want to do something complex.

> sub children {
>     my $self = shift;
>     if ( caller->isa( __PACKAGE__ ) || $self->isa( scalar(caller) ) ) {
>         return wantarray ? @{$self->{_children}} : $self->{_children};
>     }
>     else {
>         return @{$self->{_children}};
>     }
> }
>
> This is in a vain attempt to implement a protected subroutine. In
> fact, I really want a private writing accessor with a public reading
> accessor, but have absolutely no way to implement that.
>
> Why do I want such a beast? Because I want to GUARANTEE in an absolute
> kind of way that, unless my user truly intended to do so, he's not
> going to be able to accidentally screw up my internal state.

And when your user does want to, essentially say "Nah, you screwed up designing
that object protocol, children shouldn't've been protected." it's the work of a
moment to write:

   thing.send(:children, *args)

> (Oh, and Ruby has first-class block. W00T!)

And continuations. But continuations are scary. Good scary, but still scary.

-- 
Piers Cawley <[EMAIL PROTECTED]>
http://www.bofh.org.uk/

Reply via email to