T
Trans
Previously I entertained a Meta module, or using ObjectSpace for these
meta-coding commands. But thats a bit wordy. Today I thought about how
these specific commands are kind of sacred. Then I thought global vars
are kind of like that too. So:
$id = lambda{ |obj| Kernel.instance_method
object_id).bind(obj).call
}
$class = lambda{ |obj| Kernel.instance_method
class).bind(obj).call
}
$dup = lambda{ |obj| Kernel.instance_method
dup).bind(obj).call }
class X
def object_id ; "sabatoge" ; end
def class ; "sabatoge" ; end
def dup ; "sabatoge" ; end
end
x = X.new
p x.object_id
p x.class
p x.dup
p $id[x]
p $class[x]
p $dup[x]
It's concise and we avoid keywords and cluttering the object's method
namespace.
You thoughts on "holy" commands?
T.
meta-coding commands. But thats a bit wordy. Today I thought about how
these specific commands are kind of sacred. Then I thought global vars
are kind of like that too. So:
$id = lambda{ |obj| Kernel.instance_method
}
$class = lambda{ |obj| Kernel.instance_method
}
$dup = lambda{ |obj| Kernel.instance_method
class X
def object_id ; "sabatoge" ; end
def class ; "sabatoge" ; end
def dup ; "sabatoge" ; end
end
x = X.new
p x.object_id
p x.class
p x.dup
p $id[x]
p $class[x]
p $dup[x]
It's concise and we avoid keywords and cluttering the object's method
namespace.
You thoughts on "holy" commands?
T.