facets icon indicating copy to clipboard operation
facets copied to clipboard

Eigen vs Module methods

Open trans opened this issue 10 years ago • 3 comments

I am considering adding the method alias_class_method to the Module class. However, it seems wasteful to have to add a special method for this, just as it seems wasteful for similar methods like class_accessor. We end up with a bunch of methods that are nothing more then copies of methods that already exist, but acting on the singleton class instead.

Facets has Kernel#eigen which can be used like so:

class Foo
  eigen.alias_method :foo, :bar
  eigen.attr_accessor :baz
end

Not sure I like the eigen name. It used to be called meta but that seemed way too generic. But the question is: Is eigen a better approach? Or should we just be happy with a bunch of extra module methods? Or should we just support both?

trans avatar Apr 10 '14 20:04 trans

Without expressing any personal preference I believe that singleton[class], meta[class] and eigen[class] are used with descending frequency.

Personally I prefer metaclass

RobertDober avatar Jun 06 '14 22:06 RobertDober

Thanks, that helps. I'll start the process of deprecating eigen. The term eigenclass was _why's baby. I suppose he's been gone long enough now.

I'm still not sure if I should bother to add alias_class_method. Which would you prefer to see in code:

class Foo
  metaclass.alias_method :foo, :bar
end

Or

class Foo
  alias_class_method :foo, :bar
end

trans avatar Jun 08 '14 01:06 trans

I prefer the first, its semantic is clear for me, although you chose a good name, it still is only a name, I feel it does not enough "work" to justify its existence. Just my 2c. BTW Nice to know about the origin of eigen.

RobertDober avatar Jun 08 '14 06:06 RobertDober