Understanding the Typesystem

Hi everyone,

I am currently looking into the Typesystem of MPS and was wondering how the following situation is being resolved:

int i;
i = 1; // ok
i = new Integer(2); //ok
i = new Boolean(true); // error

I was going through the Typesystem Trace and was also looking into the respective implementation aspects of BaseLanguage. I would like to understand why the Typesystem allows either a Integer literal or an instance of the Integer concept but rejects a Boolean. Where can I find the rule saying that a int and a Integer can be used interchangeably in this context? Where is the distinction between Integer and Boolean made. I couldn't pinpoint the exact rules yet.

1 comment
It is the two "weak" sub typing rules named "int_boxing" and "int_unboxing" that define that either is a sub-concept of the other.


Please sign in to leave a comment.