hoodwink.d enhanced
RSS
2.0
XHTML
1.0

RedHanded

Forgiving Your Infidelize #

by why in bits

Just noticed RCR 290 Add warning for misspellings of ‘initialize’—which attempts to break Ruby’s silence on method misspellings. Here’s duck typing’s largest weakness, since functionality depends on matching method names.

Florian Gross provides a method_added hook for sniffing out imposters to initialize:

 class Class
   def method_added(name)
     if not private_instance_methods(false).include?("initialize") and
       name.to_s[/\Ain[^_]{1,6}li[sz]e\Z/] and name != :initialize
     then
       warn "warning: probably misspelled `initialize' as `#{name}'" 
     end
   end
 end

His regular expression is pretty liberal and I thought I would check for other possible valid matches in /usr/share/dict/words.

 $ grep -e '^in\w\{1,6\}li[sz]e$' /usr/share/dict/words
 infernalize
 infidelize
 informalize
 initialize
 insulize
 integralize
 internalize

Anyway, I’d really like to start using infernalize as a seamless substitute. Counted lucky that the decadence can begin so early.

This blog is all about tailing flgr now. Tailing flgr and debunking his code. Up next: flgr spotted on the f-train with actor-slash-entertainer Taye Diggs!! Discussing the merits of Dharma Punx!! Gads!!

Comments are closed for this entry.