Further Dementia

I got an e-mail response from ged/m.g. today concerning the demented wishes. He pointed out that Ruby 1.8 does have Class#define_method. So I peeked into rb_mod_define_method() to see how it works exactly.

As you’d suspect, Procs and blocks are basically converted to Methods. Given a name and bound to a class. Which has me wondering why all Procs shouldn’t just become Methods. The default would be for each block to be a method belonging to a singleton of a scope instance. That way you could access the methods of that scope and store metadata during a block’s execution.

Here’s some proof-of-concept code. There are certainly problems with this idea. It feels dangerous, but I figure that this is one entry on one small site and out of view. Please don’t squeal on me.

 class ProcScope
  attr :count
  def initialize( &p )
   class << self
    define_method( :proc_call, &p )
   end
   def call( *x )
    @count ||= 0
    @count += 1
    proc_call( *x )
   end
  end
 end

 class Array
  def each_p( &p )
   s = ProcScope.new( &p )
   each { |x| s.call( x ) }
  end
 end

 [ 'a', 'b', 'c' ].each do |x|
  puts count
 end

I’m still not sure what I think about the whole idea. It’s neat. Solves some problems. Creates some problems. I just know there’s a good angle on this. Looking for it…

disoriented?

why the lucky stiff
is a fledgling freelance professor, one who will die young and make no lasting impression.

except there was that time when i vacuumed all of Greenland for them.

email? here.

Books:
  • Why's (Poignant) Guide to Ruby (Blixy Tees)

    Blogs:
  • quiet
  • Hackety Org
  • RedHanded COMPLETED!

    Stories:
  • The Bobby Wolves
  • Stunt Runner

    Comics:
  • Holy Bible: one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen
  • The Open Window: one, two, three, four, five, six, seven, eight, nine
  • Lost Children, Lost Children, Lost Children, See Such Feverish Castles: one


  • Incidents: (35) Adventure of the Apple's Mom (34) A Magic Milk (33) The Secret Sandwich (32) A Smart Curtsy (31) The Hand Which Fell Apart (30) Jentle & Pailey (29) The Grieving Boar (28) The Story Life Doesn't Explain (27) The Life Guy (26) The Jump Wanter (25) Kimothy's Mouth (24) Speaking Of Flutes (23) The Advisor (22) Wristwatches (21) The Queen-Sized (20) The Tandem Bicycle (19) The Little Piece of Cloth (18) Milk Powers (17) Javek and the Candle (16) The Skier (15) The Man Who Happened to Have Legs (14) The Man Who Happened to Reach Up (13) Duck Typing (12) The Incident (11) The End (10) Ghosts (9) The Man (8) Waking (7) Water (6) Birthstones (5) Ignored (4) The Berkowitz Manuevre (3) Regrets (2) Emptiness (1) The Milkman Who Couldn't Sleep

    Five-Minute Plays for Twins Who Don't Have Their Other Twin With Them and An Unlimited Supply of Animals: Octopus, Eagle, Swan, Otter

    Quatrains: 0.0, 0.1, 0.2, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5

    Hacking:
  • The Fully Upturned Bin
  • Seeing Metaclasses Clearly
  • What's Shiny and New in Ruby 1.8.0?
  • A Quick Guide to SQLite and Ruby
  • The Little Coder's Predicament
  • Wearing Ruby Slippers To Work

    Feeds:
  • RSS 2.0
  • Atom 0.3
  • !okay/news

    Hobix 0.4 is the white pantsuit underneath it all.