Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Specialized type tests #5566

Open
CeylonMigrationBot opened this issue May 25, 2015 · 7 comments
Open

Specialized type tests #5566

CeylonMigrationBot opened this issue May 25, 2015 · 7 comments

Comments

@CeylonMigrationBot
Copy link

[@tombentley] While working on serialization I've come across the need to know about the types of instances at runtime which our existing metamodel APIs don't satisfy very well.

  • Knowing that something is an Array (of any element type). Because Array is invariant I can't use is Array<Anything>. The best I have currently is type(instance).declaration == class Array`` which is hardly egronomic and (given all I really need to do is an instanceof must perform terribly too).
  • Distingushing a Span from a Measure. Because Span and Measure are not shared from the language module I can't use is Span<Integer> for example, because uttering Span is verboten. My work around for this is the positively spine chilling type(instance).declaration.qualifiedName == "ceylon.language::Span".

[Migrated from ceylon/ceylon.language#688]

@CeylonMigrationBot
Copy link
Author

[@tombentley] Oh, and another related thing, as the above examples demonstrate, I end up going type(instance).declaration a lot. This requires construction of a ClassModel just to obtain it's ClassDeclaration. Having a ClassDeclaration classDeclaration(Anything instance) we could avoid that.

@CeylonMigrationBot
Copy link
Author

[@gavinking] @tombentley why can't you use is Array<out Anything> array ??

@CeylonMigrationBot
Copy link
Author

[@gavinking]

Having a ClassDeclaration classDeclaration(Anything instance) we could avoid that.

That would be nice, I agree.

@CeylonMigrationBot
Copy link
Author

[@tombentley]

@tombentley why can't you use is Array<out Anything> array ??

Because I keep forgetting we have use-site variance I suppose.

@CeylonMigrationBot
Copy link
Author

[@tombentley] @gavinking is there a reason why Span and Measure can't be shared? I know we don't want people to instantiate them directly (but use span() and measure()), but we could make them sealed. That way at least we can refer to their type.

@CeylonMigrationBot
Copy link
Author

[@gavinking] Well, so we can change that design later. I mean there's not really a huge difference between a "span" and a "measure", they are much the same thing.

@CeylonMigrationBot
Copy link
Author

[@FroMage] Moving to 1.3.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant