--8323328-435739242-11225613364494
Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-435739242-1122561336=:14494"

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--8323328-435739242-11225613364494
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE

On Thu, 28 Jul 2005, Daniel Brockman wrote:

>> i'd say __all__ code depends on that.  otherwise
>>
>>    module M
>>      def self::new
>>        raise
>>      end
>>    end
>>    class C
>>      include M
>>    end
>>
>>    c = C::new
>
> Surely you are not suggesting that all code defines
> singleton ewmethods on modules?
>
> Considering that this doesn't work,
>
>   class X
>     def self.new
>       raise
>     end
>   end
>
>   class Y < X
>   end
>
>   x = X.new
>
> why do you expect your example to work?

well - you have to actually __use__ the method - i was pointing to the fact
that they are inherited in the case of subclasses and are not in the case of
mixins ;-)

   harp:~ > cat a.rb
   class X
     def self.new
       raise
     end
   end

   class Y < X
     def self.new; super; end
   end

   x = X.new

   harp:~ > ruby a.rb
   a.rb:3:in `new': unhandled exception
           from a.rb:11


> I don't get why Y's singleton class inherits from X's,
> while C's *doesn't* inherit from M's.

because otherwise including module could clobber class methods which generally
include hooks to create instances like 'new', 'instance', 'parse', etc.  ifou
replace the set of methods responsible for stamping out instances you are not
'mixing-in' functionality to those instances - but changing what type those
will be.  there is a fundemental difference here.

> Why are you defining M.new?  Do you have actual code that > does this?

tons.  just yesterday i was writing a parser.  all the code is wrapped in a
module to protect namespaces.  each line of the file i am parsing is a command
sent to a satelite.  i have a factory which produced command objects of a
given type that's arranged like

   module Command
     class Abstract
       ...
     end
     class Load < Abstract
       ...
     end
     class Sub < Abstract
       ...
     end
     class Add < Abstract
       ...
     end
     class Store < Abstract
       ...
     end
     def self::new line
       orbit_normal_time, command, register, value = parse line
       klass =
         case command
           when /load/
             Load
           when /sub/
             Sub
           when /add/
             Add
           when /store/
             Store
         end
       klass::new(orbit_normal_time, register, value)
     end
   end

however, i actually use this class in another like

   class PayloadActivationMessage < AbstractMessage
     include Command
   end

and this would change the notion of calling 'super' if what you are suggesting
were true.  eg - if 'some_method' were defined as a class method in
PayloadActivationMessage, AbstractMessage, and Command, then a definition like

   def PayloadActivationMessage::some_method
     super + 42
   end

would seem to call AbstractMessage::some_method (due to inheritence) but would
actually call Command::some_method if class methods were automatically pulled
in by 'include' statements.  there are cases where you want this and that's
what 'append_features' is for - but to have this for the normal case would be
quite suprising for most applications i think.  not to mention changing the
notion of super is, be definition, a very strong form on inheritence.

> No, it would not be possible to retain full backwards compatibility, but I
> cannot think of a real-world case in which actual problems would result.

added multiple inheritence semantics for module inclusion would not be
backwards compatibile imho.

>> inheritence needs to be addressed specifically for it to make sense.
>
> Why do you say that?

well - because that's what you are suggesting!?


pine, mutt, or mail.

but even the web interface shows the problem:

   http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/149703

look at the line with 'const char' on it.

cheers.

-a
-- 
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| My religion is very simple.  My religion is kindness.
| --Tenzin Gyatso
===============================================================================

--8323328-435739242-11225613364494--
--8323328-435739242-11225613364494--