Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. (a) Suppose int is a subtype of float in a language with subtyping and implicit conversions but no polymorphism (Suppose also that int has
2. (a) Suppose int is a subtype of float in a language with subtyping and implicit conversions but no polymorphism (Suppose also that int has no proper subtypes and float has no proper supertypes.) If the following program is well-typed, what is the type of the function f? float x, y; if (f (x) mod 3 2) then y -f (5); mod only accepts arguments of type int. Explain. (b) Modify the program so it works when an explicit conversion i2f is required to cast an int value into a float value. 2. (a) Suppose int is a subtype of float in a language with subtyping and implicit conversions but no polymorphism (Suppose also that int has no proper subtypes and float has no proper supertypes.) If the following program is well-typed, what is the type of the function f? float x, y; if (f (x) mod 3 2) then y -f (5); mod only accepts arguments of type int. Explain. (b) Modify the program so it works when an explicit conversion i2f is required to cast an int value into a float value
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started