fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

Unclear edge cases of type features

Open simonvonhackewitz opened this issue 1 year ago • 5 comments

Is Type a cotype? Are inner or inherited features of Type type features?

Since all cotypes inherit from Type and their inner features are type features, the features a cotype inherits from Type are type features by definition.

Type has no explicit parent, so it inherits from Any which means it inherits the features from Any, some features it redefines (e.g. as_string) some it doesn't (e.g. prefix $). Type does also define new features, e.g. name.

It is possible to call Type.type.as_string and $Type.type but not Type.as_string or $Type. (EDIT: this is actually due to the the visibility module:public of Type.) Its also possible to call Any.type.as_string.

Any.type.name works but not Any.name, also see #3637.

The method isTypeFeature() in AbstractFeature.java currently acts like "is cotype" and it returns false for Type.

How to check if a feature is a type feature when a cotype inherits it from Type but it is implemented in Any i.e. its outer feature is Any? And should the above examples work as described?

simonvonhackewitz avatar Sep 05 '24 10:09 simonvonhackewitz

Type is a normal feature, not a cotype. But Type does have a cotype Type.type.

Inner features of Type are normal features, but once inherited by a cotype, I think we should consider them type features.

It is possible to call Type.type.as_string and $Type.type but not Type.as_string or $Type. Its also possible to call Any.type.as_string.

I guess Type.as_string results in an ambiguous call, right? If so, does the error suggest alternatives that are unambiguous and do they work? If not, please create a bug issue.

Any.type.name works but not Any.name, also see #3637.

If Any.type.name works, I think Any.name should work as well unless ambiguous, please create a bug issue if this is not the case.

The method isTypeFeature() in AbstractFeature.java currently acts like "is cotype" and it returns false for Type.

That is a general cleanup issue, the Fuzion sources still mix up the term type feature to refer to either type features or cotypes.

How to check if a feature is a type feature when a cotype inherits it from Type but it is implemented in Any i.e. its outer feature is Any? And should the above examples work as described?

Features inherited from Any by a feature fshould appear twice, as inner features of f and as type features of f (i.e., inner features of f's cotype).

fridis avatar Sep 06 '24 10:09 fridis

Features inherited from Any by a feature fshould appear twice, as inner features of f and as type features of f (i.e., inner features of f's cotype).

But how to do the check for an AbstractFeature in the Java code? For prefix $ using af.outer().isTypeFeature() does not work, because for both Any and the cotype of Any the outer feature of is Any (because it is never redefined).

E.g. classify() in Util.java

simonvonhackewitz avatar Sep 12 '24 14:09 simonvonhackewitz

But how to do the check for an AbstractFeature in the Java code?

@fridis what was the solution to this? I remember we talked about it but I forgot what it was.

simonvonhackewitz avatar Oct 01 '24 15:10 simonvonhackewitz

But how to do the check for an AbstractFeature in the Java code?

@fridis what was the solution to this? I remember we talked about it but I forgot what it was.

TLDR: Can you repeat what you mean by this.

fridis avatar Oct 02 '24 07:10 fridis

Features from Any appear as normal and as type features and if they are never redefined, their outer feature is Any in both cases. How to differentiate those features and check if such a feature is a type feature?

simonvonhackewitz avatar Oct 02 '24 07:10 simonvonhackewitz

Closing this because points have been clarified or moved to separate issues.

simonvonhackewitz avatar Oct 08 '24 15:10 simonvonhackewitz