hoodwink.d enhanced


Siphoning the Keywords Out #

by why in inspect

Our PorCUpinECaSe bosom friend MenTaLguY is forsaking keywords and reveals the look of Ruby without such crutches.

 (Frink::Gromzalot = Class::new).class_eval {
   define_method(:zork) {
     puts "Zogmorfo" 

My eyes say this is like looking at exposed circuitry, like transparent case Gameboys and telephones, but I’ll bet one of ya could put a nice mutant veneer over it to cozy it up, push it beyond.

said on 10 Aug 2005 at 11:51

Heh, I had a fascination with transparent-case doodads in my Middle School days. Transparent phone, transparent watch, transparent radio, transparent clock. Predated Gameboys, though, I think… certainly the transparent ones.

As for transparent-case Ruby … the one thing I’ve not been able to solve is how to define singleton methods whilst still entirely avoiding keywords.

Many coats to them who figures that bit out…

said on 10 Aug 2005 at 12:02

No reason to use .class_eval there:

Frink::Gromzalot = Class.new {
  define_method(:zork) {
    puts "Zogmorfo" 

Class.new and define_method() are actually quite common idioms once you’re doing meta-programming.

said on 10 Aug 2005 at 13:42

Ahh, good catch. I’d forgotten about Class::new’s block parameter.

said on 10 Aug 2005 at 16:14

Looks like a dentist is trying to eleminate evil syntax sugar like “class” and “def” in his code :) Save your teeth with meta programming!

Wonderful idea, DenTaLguY ;) I’ve made a small time-saving framework:

def method_missing m, *a, &b
    self.class.const_set m, Class.new(&b)

class Class
    alias O new
    def method_missing m, *a, &b
        define_method m, &b

and now this code runs without problems:

Kill { Zap { puts 'Peng.' } }
Kill.O.Zap  #-> Peng.

The possibilities!

said on 10 Aug 2005 at 16:51

works for me!

said on 10 Aug 2005 at 20:04

murphy: that’s brilliant *_*

Comments are closed for this entry.