-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make everything an Object #144
Comments
So Object.ACCEPTS should... Just return true? :P |
That's the gist of it, yes. (007 doesn't have an Perhaps more importantly, it means that properties that |
All of a sudden I'm uneasy about a choice I made early on with objects: that the Though I can't quite put my finger on it, I think this will interact badly with #33. This issue makes it a bit clearer why that might be.
This violates Liskov substitutability, and leads to the usual problems when doing upcasts.
Perhaps my biggest shame in all of this is that I've for a long time disliked what Perl 6 does with the type hierarchy and Currently I'm thinking of whether to fix this. An obvious fix would be this:
|
why does this compile fine though? |
Oh, sorry, I just noticed I had a typo in the example I wrote:
The last line should of course be
Does that make it clearer why it compiles fine? |
Yes, much more sense :) |
Then: I'm very much against a top type that's Hash. |
I agree with my past self about After all, if |
Putting |
I'm increasingly convinced that we're going to need to abandon types declared in Perl 6 using Perl 6's What we need to do is to get ourselves a minimal MOP-like thing, with a Edit: There's now #242. |
Here are the things that we'd expect to work once
|
Essentially, this is going to push us to having a userland boolification protocol. And a stringification protocol too, from what I can see. My initial idea is to just call those methods |
In starting this one, I realized pretty soon that #184 is blocking on it. |
Oh, mostly because the Though, hm, I guess in a pinch it could do a poor-man's dictionary by being an Array, so it's not a total blocker... |
I'm going to slap the "needs-more-design" label on this one, because likely there are more horrors lurking in these waters, similar to the boolification protocol thing. For example, it does feel like 007 will need to be aware of the primitives/reference types distinction in some way, but I'm not sure how. Can you create several instances of the |
Been thinking about this one. I think one significant first step could be had by declaring |
This has been neatly resolved in #242. The answer is that no, 007 doesn't have primitive types. However, some types are "wrapped" and their exact specification disappears into the Perl 6 layer. |
This re-establishes Val::Object, but this time as the kind of empty type that goes at the top of a type hierarchy. As a consequence, "everything is an Object", which right now is hard-coded into the ~~ and !~~ operators. In the fullness of time, we'll instead code it into the type hierarchy itself, so that a special case is not needed. Closes #144.
This re-establishes Val::Object, but this time as the kind of empty type that goes at the top of a type hierarchy. As a consequence, "everything is an Object", which right now is hard-coded into the ~~ and !~~ operators. In the fullness of time, we'll instead code it into the type hierarchy itself, so that a special case is not needed. Closes #144.
This re-establishes Val::Object, but this time as the kind of empty type that goes at the top of a type hierarchy. As a consequence, "everything is an Object", which right now is hard-coded into the ~~ and !~~ operators. In the fullness of time, we'll instead code it into the type hierarchy itself, so that a special case is not needed. Closes #144.
Currently
Int
s are notObject
s:This issue makes the case that they — and in fact everything — should be.
The usual case against making "primitive types" not inherit from
Object
is performance: they need to be closer to the metal so they can be fast. 007 has no such concerns. Languages like Java have done weird, unnerving dances withInteger
wrapper types, just to have somewhere OO-y to store properties and methods. In a move nobody quite understands, JavaScript copies this design, and somehow makes it worse.Ruby takes the stance that fixnums are objects, because hey, everything is:
I'd like to take this stance in 007 too, but I believe I have an even better argument than just "everything's an object": an object is something that you do property access on. Do our ordinary
Int
andStr
andArray
values have properties? Yes, they do! Hence, we'd expect them to be a kind of object.Of course, this goes for
Q
nodes, too. They're just a type of object, and should typecheck as such. They don't, currently:The text was updated successfully, but these errors were encountered: