Comments (3)
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
orMetaAnything
.- If
MetaAnything
were its own class, you'd be able to sendMetaAnything :new
. But there's no point to having the ability to make newMetaAnything
s. It seems like trying to do that should be an error -- a:method-missing
error. - That leaves
Anything
.
- If
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.
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.
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)
- algo.monads dependency HOT 5
- :__own_symbol__ => :__class_symbol_of_instance__ HOT 2
- Better example for generic functions?
- 16.4 Exercise - NullPointerException HOT 2
- Confusion on Exercise 16.5.5 HOT 1
- More background in "Functional Style" part?
- diagram for double dispatch
- Does Light Table require `(use 'clojure.pprint)`
- typo in code HOT 1
- Typos HOT 1
- The separate function DOES exist HOT 1
- Second method of embedding functional code in OO should not be so easy to miss
- garrulous gastropod - chapter 5 exercise #5 has no published solution
- garrulous gastropod - better naming of source & solutions files? HOT 2
- errata: chapter 8 (p. 102) Incorrect method name reference (garrulous gastropod) HOT 1
- boolean vs not not HOT 1
- Comments/errata on "garrulous gastropod" HOT 2
- Regarding ex. 1 chapter 7.9 HOT 1
- Can't use nomads HOT 4
- book/repo currently not working "out of box" due to lein 2 changes to default setup HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fp-oo.