Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN ML : a. Ada must sometimes use the context of a function call to determine which overloaded definition to use. Consider the statemente :=

IN ML :

a. Ada must sometimes use the context of a function call to determine which overloaded definition to use. Consider the statemente := f(f(a,b), f(c, d)) in an Ada-like language. Give an example of a set of types for the overloaded function f that makes this statement ambiguous, even whenthe types of a, b, c, d, and e are known.

b.

Consider an unknown language with itneger and real types in which 1+2, 0+2, 1+2.0, and 0+2.0 are all legal expressions.

a. Explain how this could be the result of coercion, using no overloading

b. Explain how this could be the result of overloading, using no coercion.

c. Explain how this could result from a combination of overloading and coercion.

c.. Consider an unknown language with integer and string types in which 1+2*3 evaluates to 7, "1"+"2"+"3" evaluates to "123", "1"+2+3 evaluates to "123", and 1+"2"+"3" has a type error. Describe a system of precedence, associativity, overloading, and coercion that could account for this. In your system, what is the result of evaluating the expression "1"+ 2*3?

d.

Write an ML function definition for each of the following functions. Try to predict what polytype ML will infer for each funtion. Then check your prediction using the ML language system. What is the polytype determined by ML for each case?

a. f(x) = 1

b. f(g) = g(1)

c. f(g, x, y) = g(x, y)

d. f(g, x) = g(g(x))

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

Database And Expert Systems Applications 23rd International Conference Dexa 2012 Vienna Austria September 2012 Proceedings Part 1 Lncs 7446

Authors: Stephen W. Liddle ,Klaus-Dieter Schewe ,A Min Tjoa ,Xiaofang Zhou

2012th Edition

3642325998, 978-3642325991

Students also viewed these Databases questions