CSC 123/252 Study Guide for the Final Exam.
The final exam will *mostly* focus on the material covered after the
midterm. However the exam will implicitly require understanding of
fundamental topics such as static/dynamic scoping and closures.
Writing code fragments in F# and Rust will be required.
==Topics:
C# covariance and contraviance in generics
F# programming, including:
Understanding how types are handled (polymorphic inference, static safety).
Discriminated union type definitions (as in type expr = |... |...).
Pattern matching.
Writing some code fragments.
Features will reflect those emphasized in class and used in ASSIGNMENTS
**Understand the relationship between F# pattern matching and dynamic
dispatch and the visitor design pattern. How does F# compare to
dynamic dispatch and to "multiple dispatch" in Julia.
Rust and Related Topics
C++ unique_ptr, shared_ptr and weak_ptr (in Rust, Box, Rc and
Weak pointers). You don't have to write code but you need to
answer specific questions about their use, as well as their
limitations (how they compare to Rust).
Where memory errors can occur in C/C++; what "Zero Overhead Abstraction"
means in C++ compared to Rust.
Understand the Rust rules of ownership, lifetime, and borrowing, and
be able to write small Rust programs and answer questions about
Rust code.
Rust lifetime parameters ( <'lt> ) and their usage.
Study sample Rust programs, including (but not limited
to) wymk.rs, nicerust.rs (pattern matching and expression trees),
and options.rs, as well as your Rust programming assignments.
Know how to use the Option monad in Rust.
Another type of question on the exam will be to see if you understand
the relative tradeoffs between all the languages we studied. This
topic was covered extensively using the different EXPRESSION TREE
PROGRAMS that we saw in the different languages.
----------------------------------------------------------------------------
How to Study:
Do the sample problems here without looking at the answer.
Do NOT just memorize definitions or simply learn the mechanics without
understanding their purpose.
Study previous programming assignments.
---- Sample questions to prepare for the final exam ----
Answers posted separately
1. What are the tradeoffs between inheritance with dynamic dispatch in OOP
languages such as C# and pattern matching in F#.
1b. How does pattern matching in F# compare with multiple dispatch in Julia.
Are the two approaches equivalent?
2 Write the closest equivlent F# program of the following C# program.
Your F# program may contain AT MOST EIGHT lines of code
interface llist {}
class Nil : llist {}
class Cons : llist
{
public A head;
public llist tail;
public Cons(A h, llist t) {head=h; tail=t;}
}
public class llists
{
static string check(llist m)
{
string answer = "";
if (m is Nil) answer = "empty";
else if (m is Cons) {
if (((Cons)m).tail is Cons) answer= "at least two";
else answer = "just one";
}
return answer;
}//checkp
public static void Main()
{
System.Console.WriteLine( check(new Cons(2,new Nil())) );
}//main
}
3.
Describe what will happen with the following C# segments of
code, in terms of any compiler errors, or runtime errors, and EXPLAIN WHY
// assume using System; and using System.Collections.Generic;
a. object[] A = new string[10];
A[0] = 1; // 1 is not a string but it's an object
b. List