Topics for ITEC320 Exam02, 2018fall


Page last generated
  - Consider the following roughly-equivalencies: 

       english    metric   power     power    binary
        word      prefix   of ten    of two   prefix
       ------     ------  -------   -------   -----
      thousand  =  Kilo  = 10^3   ~  2^10  =  Kibi
      million   =  Mega  = 10^6   ~  2^20  =  Mebi
      billion   =  Giga  = 10^9   ~  2^30  =  Gibi
      trillion  =  Tera  = 10^12  ~  2^40  =  Tebi

    Exam questions might choose one entry in the table above,
    and then ask for one of the other values in that row:
    E.g. "2^30 is which metric prefix (approx)?"
    or "1K is what power of 2?"


    Also good to know: 
      - exact powers-of-two up to 10;
      - able to reason that (e.g.) 2^32 = 2^2 * 2^30 = 4G
      - realize that (say) 2^16 is how high you can count, if you have 16 bits
                just like 10^16 is how high you can count, if you have 16 decimal-digits.
      - These don't apply only to "B" (bytes); you can have
        a kilo-meter, a kilo-gram, a kilo-byte, or a kilo-donut (mmmm).
      - We won't use the binary-prefixes at all, though it's good to know 
        how to not to use the metric-prefixes incorrectly, 
        e.g. "This chip can access 16 GiB of memory" rather than "16GB".]
     
        
        
        
        
      
                              somewhat-similar concepts in each of:  [VERY rough!]
                            --------------------------------------------------------
                              Ada                     C                      Java 
                             -----                   ---                    ------
type-conv. @compile?     must be explicit        casting circumvents!  numeric widening; `toString` often implicit
type-conv. @run?         checked(sub-types)      not checked           cast does run-time check of objects
init.vars                no (initially garbage)  no                    yes (fields zero'd; locals must init-before-use)
aggregate types:         record                  struct                class
re-name types            y; non-interchangeable  y; interchangeable    no
regluar functions        function/procedure      function              static-method
O.O. functions           {not in 320}            {C++ only}            method (non-static/O.O.)
packages                 with                    {only via linking}    CLASSPATH
abbr.full names          use                     #include              import
aggregates:comparison    component-wise =        compare bits ==       reference-equality only   ==
aggregates:assignment    component-wise :=       assign bits =         reference-assignment only  =
immed.mem vs pointer     both {ptrs next week!}  both                  references-only
   (aka value- vs reference-semantics)
compiling                to .o's, then link      to .o's, then link    to .class; jvm loads other .class at run-time

     Observation:
     In spirit C and Ada tend to be similar (but Ada enforces type-safety)
     Java and Lisps tend to have similar memory-model (but static vs dynamic typing)

value- *and* reference semantics?
    Ada: both allowed  (though we've only talked about value-semantics)
    C: both allowed
    C++: both allowed
    Java: only reference-semantics for objects (and value-semantics for primitives)
          [technically: Java only has pass-by-value, BUT the values are all 'object-reference' (plus a few primitives)]

    Note on pass-by-reference in C: the programmer has to wrestle with pointers themselves, to achieve this effect
         (referencing (`&`) and de-referencing (`*`) and manually.
         (C++ has proper syntax for this, so the compiler can automate this pointer-wrangling or even optimize it away)

         In a similar vein, Ada's in/out params might even get optimized to use pass-by-reference when
         it can be prove that the results are equivalent to pass-by-value.

The remainder of this file is © Dr Ned Okie; used by permission. Any formatting-errors are probably mine. --ib

Material


Records


Nested Composite Types:

Value vs reference semantics:


ADTs & Packages


The following are not on this semester's Exam 2 (unless listed above)