From: Logan Capaldo Date: 2006-05-13T04:42:29+09:00 Subject: Re: final/closed classes in Ruby (was: Sharp knives and glue) On May 12, 2006, at 10:05 AM, Berger, Daniel wrote: >> -----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. > 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.