The Social Media Language (SML) has the following built-in data types: comment message
Need help in this question with detailed explanation
Info given-
The Social Media Language (SML) has the following built-in data types:
comment
message
account
picture
message
The format of functions in SML is as follows:
<return_type> <function_name> (<parameter1> , <parameter2>, …, <parameter_n>)
SML has the following built-in operations:
account post (comment, message, account);
account post (picture, account);
account delete (message, account);
account delete (picture, account);
account find (comment, account);
message search (picture, account);
account share (account, account);
SML also has the following built-in conversion functions:
comment comment_of (picture);
comment about (account);
account friend_of (account);
account add_on_of (picture);
picture picture_of (comment);
The conversion functions convert the value of its parameter, and then returns converted value. The parameter remains unchanged.
Other features of the language are as follows:
- The language is not case sensitive.
- Coercion is performed only from comment to picture, and from message to picture; meaning, if the actual data type is either a comment or a message, and the expected data type is a picture, the value of the comment or message is automatically converted to a picture.
- Static type checking is performed whenever sufficient information has been provided by the programmer to the compiler. Otherwise, type checking is deferred until runtime.
- Variables do not have to be explicitly declared. Those that are not declared explicitly and start with a letter between I and N (inclusive) have the data type comment (part of the language definition). Any other undeclared variables are typeless; that is, their data type is determined based on the type of the value that was most recently assigned to them.
- The assignment operator is :=. Both operands of the assignment operator must have the same data type (meaning <type> := <type>, and := returns void.
Given the following variable declarations:
var ig : account;
meme : picture;
primary : comment;
arrow : account;
Q1)
Answer the following sets of
Line 2: ig := delete(result, ig);
e) Will a data type mismatch error occur in Line 2?
f) If your answer in the previous question is YES, rewrite Line 2. If your answer in the previous question is NO, select "NA"
OPTIONS FOR RWERITING LINE 2 ARE AS FOLLOW:(CHOOSE THE RIGHT OPTION AMONG THE GIVEN)
1)ig : delete(picture_of(about(result)), ig)
2)ig:= delete(add_on_of(about(result)), ig)
3)ig : delete(friend_of(about(result)), ig)
4)ig: delete(comment of(about(result)), ig) 5) NA
g) What is the data type of ig after Line 2?
OPTIONS- FOR G (CHOOSE AMONG THE FOLLOWING)
1) account
2) picture
3) message
4) comment
Step by step
Solved in 3 steps