From: Stu Date: 2013-02-22T07:55:08+09:00 Subject: Re: How meta class differs from real class ? On Wed, Feb 20, 2013 at 3:54 PM, Xavier R. wrote: > In Ruby- > > Could anyone help me to understand how meta class differs from real > class ? > > Examples with discussion could be better to understand the core of the > concept > Core concept for meta class is that every class has it's own class. One view would be that it's an anonymous class or hidden class as I've seen explained. Instead of producing and example for you as they can provide a handful of use cases and design concepts for your program's model it may be better for you to view various takes on the interwebz for it's general concept though various combinations of code and style. More importantly it may be useful to understand that a meta class is just as real as a class though it's scoping does not follow the normal method lookup chain at the top level instance. One may also consider further modification after the instance is constructed by redefinition of the instance object. Take the time and experiment with both opening up the meta class in your class templates. Create your own macros( for example try to make your own attribute generators). explore post instantiations with singleton assignment and delegations. More importantly explore these concepts within the repl and editor combination. Think of the concept that Matz created ruby to be a "Programmable Programming Language". Though that quote was from another language which heavily influenced ruby it's a major part of ruby's computational model. Also instead of getting stuck on the recursive writing style of various tutorials which attempt to verbalize the Class<=>Object relationship and paradigm consider simply taking the time and coding simple functions yourself while viewing the yielded results from trial and error will provide you more substantial experience on grokking the interpreter (as well as how the interpretation of the code works) which will get you closer to understanding the sheer power and control available to you with this overly malleable and versatile programming language. If you are really stuck work though this one: http://madebydna.com/all/code/2011/06/24/eigenclasses-demystified.html Though the link to _why's metaclass earlier in this thread should also be explored as well as many of the other blog posts which disseminate the subject exhaustively. Metaprogramming in Ruby: It’s All About the Self was another one which provides trivial examples. For real world examples you'll want to explore how domain specific micro-languages in ruby are implemented which will provide the end result of combining the automata, stream processing, and list reference and recursion techniques within the context of the programming language. ~Stu