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. There
may be questions asking you to relate/translate programs in other languages
into F# and Rust.
Writing code fragments in F# and Rust will be required.
==Topics:
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.
Understand how simulated dynamic scoping was used in the implementation
of 'advice' that can alter the behavior of globally defined functions -
this technique was used in both Perl and F# (when we made eval a
mutable variable so we can modify it later).
Rust and Related Topics
Understand C++ unique_ptr, shared_ptr and weak_ptr. 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).
Understand the Rust rules of ownership, lifetime, and borrowing, and
be able to write small Rust programs and answer questions about
Rust code.
Advanced Rust that involves lifetime parameters <'a> will be
covered to the extent seen in your assignments.
Study sample Rust programs, including (but not limited
to) wymk.rs, nicerust.rs (pattern matching and expression trees)
and newlists.rs (linked lists using Box smartpointers), as well
as your Rust programming assignments.
Monads, specifically the Option and Result monads and study the
sample "Maybe" monad in my own implementation.
AOP/AspectJ programming (lightly covered, if at all): the main capabilities
of AspectJ. This will be a light topic on the exam, if it appears
at all. You won't have to write or analyze detailed AspectJ code.
However, you may be asked to contrast AspectJ with attempts to implement
AOP features in Perl and F#. For example, how dynamic scoping is useful
in simulating the effects of advice on programs. What features are still
missing in these languages that AspectJ provides (extension methods,
changing types).
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#.
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
}
. Given the F# definition of a polymorphic linked list structure:
type 'a llist = NIL | Cons of ('a*'a llist);
What would be the closest equivalent definition in C#. Defend your answer.
3. (maybe on final because of unsatisfactory performance on midterm)
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