Forum: Ruby Re: final/closed classes in Ruby (was: Sharp knives and glue

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F3b7b8756d0c7f71cc7460cc33aefaee?d=identicon&s=25 Berger, Daniel (Guest)
on 2006-05-12 16:07
(Received via mailing list)
> -----Original Message-----
> From: Logan Capaldo [mailto:logancapaldo@gmail.com]
> Sent: Thursday, May 11, 2006 5:18 PM
> To: ruby-talk ML
> Subject: Re: final/closed classes in Ruby (was: Sharp knives and glue)

> Unfortunately, it raises an exception way too late.

Too late for whom?  Yes, you can get around it, but you have to go out
of your way to do so.

Dan


This communication is the property of Qwest and may contain confidential
or
privileged information. Unauthorized use of this communication is
strictly
prohibited and may be unlawful.  If you have received this communication
in error, please immediately notify the sender by reply e-mail and
destroy
all copies of the communication and any attachments.
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2006-05-12 21:45
(Received via mailing list)
On May 12, 2006, at 10:05 AM, Berger, Daniel wrote:

> of your way to do so.
> in error, please immediately notify the sender by reply e-mail and
> destroy
> all copies of the communication and any attachments.
>

I'm defining too late as 'after the damage has been done', e.g. Bar
has already been sub-classed. I guess it comes down to a question of
does final mean no sub-classes can be created, or no sub-classes can
be used? If it means the first, than yes it is too late. I think that
the distinction is especially important in Ruby because we do have
these  #inherited style hooks, and inheriting from something can
cause all sorts of side effects (e.g. activerecord). If someone does
something like

class A < SomeClassFullOfDeepMagic
   final # don't want any subclasses of A
end

class B < A
end

and expects it to work, they may be in for a rude surprise, since the
deep magic may still happen, despite the fact that an exception is
raised.
This topic is locked and can not be replied to.