4 ms·
I worked with Yehuda for quite a while (great guy, super smart) and even having him explain it in person never got me past a mechanical understanding. You can l
by benreesman 3y ago
I worked with Yehuda for quite a while (great guy, super smart) and even having him explain it in person never got me past a mechanical understanding. You can learn the mechanics, even the implementation.
But there isn’t any blinding symmetry echoing the very thoughts of God at the end.
Which is how it’s sometimes presented.
- vidarh 3y ago> having him explain it in person never got me past a mechanical understanding Which part? The meta classes bit? The implementation is trivial: It's basic single inheritance. A meta class is just like any other class except for two basic things: * It's automatically "injected" into the inheritance chain as the immediate class of an object when you define methods on it. * It's "hidden" by some methods, like "#class" so that it looks like nothing has happened (I'm not sure that was a good choice - it creates part of the appearance that something weird is going on, though there are some context where you'd otherwise have to filter them out yourself) Most of the time people freak out over the meta class bit because they assume it's more complex than it is. Put another way: If you were to implement meta-classes in C, you'd "just" do something like this: struct Object { struct Class * class; ... }; struct Object * ob = SomeClass_new(); /* Defining a meta class inheriting from the original class */ struct Class * my_meta = Class_new(ob->class); Class_define_method(my_meta, ...); /* Whatever other setup you want for this new meta class, which is *just like any other class* */ /* Make the Meta class the new class of the object */ ob->class = my_meta; That's basically it, other than a flag to let us hide it from some methods when traversing the inheritance chain.