Giter VIP home page Giter VIP logo

Comments (3)

marick avatar marick commented on August 23, 2024

Changed the wording to "Fix this problem by adding a new link in the inheritance hierarchy."

I'm pretty sure this is the way Ruby does it. Older Smalltalk too (though I think the later versions split Object up into several pieces).

Here's the way to understand MetaAnything.

Its superclass:

  • any object must be a subclass of Anything (either direct or indirect).
  • MetaAnything is an object
  • Therefore: it must be a subclass of Anything.
  • It's a direct subclass because there's nothing to put between it and Anything.

Its class link:

  • Any object in the system must have a class.
  • Any object's class must be descended from Anything so that it has access to methods like :class and :method-missing.
  • MetaAnything is an object.
  • Therefore, its class link must point to Anything or something that's descended from it.
  • There are two choices: Anything or MetaAnything.
    • If MetaAnything were its own class, you'd be able to send MetaAnything :new. But there's no point to having the ability to make new MetaAnythings. It seems like trying to do that should be an error -- a :method-missing error.
    • That leaves Anything.

I'm going to improve the hints for these problems.

Also note that in the next release, this whole chapter moves to the optional Part V. It adds nothing to the reader's knowledge of Clojure or functional programming techniques.

from fp-oo.

chrispsn avatar chrispsn commented on August 23, 2024

Thanks Brian, that helped a lot.

Looking back, am I wrong or is MetaAnything's class arrow in the diagram pointing the wrong way (should have the arrowhead pointing at Anything)?

from fp-oo.

marick avatar marick commented on August 23, 2024

I don't think so. It has a left-pointing :class arrow that points to Anything. The arrow pointing to MetaAnything is Anything's :class arrow. So there's a weird circularity: Anything's class is MetaAnything and MetaAnything's class is Anything. (!)

Don't worry: none of this is obvious. Every time I work on such questions, I have to work it out from the beginning. It never gets intuitive.

from fp-oo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.