-
Notifications
You must be signed in to change notification settings - Fork 34
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
Allow anonymous class types to be referenced #865
Comments
So what I'm thinking of doing here is introducing a special type constructor, defined in the language spec, considered to belong to TypeOf<process> p = process; For now this would just be for the type of anonymous classes. But in future we could use it for other useful things like |
Hrm. Let me walk that back. The idea doesn't really work so well for nested |
I thought the syntax would have been |
@lucaswerkmeister The intuition behind |
Alright, so I have an experimental implementation of this, based on the original suggestion of using |
Trying this with the compiler tests yields lots of errors. Apparently |
So how exactly do we end up with a type pretending to be a Ceylon enum type for |
Sorry the model loader does do that, just found where. |
So how about I set |
Otherwise I'd have to add a new |
@FroMage And you can't use your |
So to be honest there is something a little inconsistent about this. The type of the expression This is actually the behavior I want, since |
Perhaps we could say that anonymous class types are illegal as type arguments. So you can form |
I think As for |
This is causing all sorts of issues. I now have a |
If we disallowed anonymous class types in type arguments, we’d never have to reify them, right? I don’t think we need to support |
I tried putting it in |
Apologies if this is off base - I haven't been following this closely. But might it be useful to be able to work in a type safe manner with subsets of enum values? Something like: abstract class Color(shared actual String string)
of black | white | red | green | blue { }
...
alias FordColorOptions => Set<\Iblack>;
{Car*} filterByColor(FordColorOptions favorites) { } |
Right. |
Well, no, for ceylon enums, the type actually exists. There is an actual class
I would not erase |
Sure, I'm only proposing to set this to Java enums. Ceylon enums are named anonymous. Value objects are unnamed anonymous ;) So this is more like value objects.
Well, unless we want to make it generic, I suppose you need to give me a method on |
So I have some code which on master gives me:
And on this issue's branch gives me:
Notice the difference between |
I've worked around it and made the JVM backend work after your changes. I've added I am ready to merge this when the JS backend is ready too. @chochos? |
So is the issue still just |
This works locally but anonymous classes are not directly available even if the object is shared. |
ok ready to merge in branch |
I'll merge all branches then, thanks. |
All merged, closing. |
Oh! So does that mean we're all happy with this? :-) |
@chochos I don't understand this comment? |
Well, we're not at least on the subject of syntax. I can't find in which issue I proposed different syntax (perhaps I didn't) like I discussed with you, perhaps I should open a new issue? |
@FroMage Don't open an issue unless you have an actual proposal :-) |
I do and we actually discussed it. |
Done: #1205 |
I thought there was already an issue for this, since it's an idea I had years ago. Given an
object
declaration like this:We could let you refer to the type of
process
(the "anonymous" class) using the syntax\Iprocess
.The text was updated successfully, but these errors were encountered: