From: Brian Candler Date: 2003-03-24T19:06:42+09:00 Subject: Re: Ruby lecture slides (was Strong advantages over Python) On Mon, Mar 24, 2003 at 11:51:33AM +0900, Austin Ziegler wrote: > Ruby objects are strongly typed (all types are known at compile > time) That's not how I understand it to be. Ruby's "compile time" is when the source code is parsed into an internal syntax tree, but no objects (including classes) are created at that stage. For example: 1 class Foo 2 def sayhello 3 puts "hello world" 4 end 5 end 6 Foo.new.sayhello After this code has been 'compiled', no class Foo exists. It is then run. After lines 1-5 have been run, the class Foo exists. When line 6 is run, an object of this class is created. However the class Foo really does not exist until part-way through the run-time phase of this program. Wrap lines 1-5 in 'if false...end' and the class is never defined at all. Incidentally, I presume that the symbol :sayhello in the above example _is_ created at compile-time. However even that doesn't have to be the case; to take a perverse example you could put the method name in a file which is read in at run-time: Foo.new.call( File.open("/etc/method_to_run","r").read ) Therefore, even duck-typing isn't established until run-time. Regards, Brian.