Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions