Ignore:
Timestamp:
Apr 13, 2017, 8:29:38 PM (5 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
1a16e9d
Parents:
c87eb50
Message:

penultimate thesis draft

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/rob_thesis/intro.tex

    rc87eb50 r0111dc7  
    326326Invariants help a programmer to reason about code correctness and prove properties of programs.
    327327
     328\begin{sloppypar}
    328329In object-oriented programming languages, type invariants are typically established in a constructor and maintained throughout the object's lifetime.
    329330These assertions are typically achieved through a combination of access-control modifiers and a restricted interface.
    330331Typically, data which requires the maintenance of an invariant is hidden from external sources using the \emph{private} modifier, which restricts reads and writes to a select set of trusted routines, including member functions.
    331332It is these trusted routines that perform all modifications to internal data in a way that is consistent with the invariant, by ensuring that the invariant holds true at the end of the routine call.
     333\end{sloppypar}
    332334
    333335In C, the @assert@ macro is often used to ensure invariants are true.
     
    617619Tuples support named access and subscript access, among a few other operations.
    618620\begin{scalacode}
    619 val a = new Tuple3[Int, String, Double](0, "Text", 2.1) // explicit creation
    620 val b = (6, 'a', 1.1f)       // syntactic sugar for Tuple3[Int, Char, Float]
     621val a = new Tuple3(0, "Text", 2.1) // explicit creation
     622val b = (6, 'a', 1.1f)       // syntactic sugar: Tuple3[Int, Char, Float]
    621623val (i, _, d) = triple       // extractor syntax, ignore middle element
    622624
     
    661663Still, @printf@ is extremely limited, since the format codes are specified by the C standard, meaning users cannot define their own format codes to extend @printf@ for new data types or new formatting rules.
    662664
     665\begin{sloppypar}
    663666C provides manipulation of variadic arguments through the @va_list@ data type, which abstracts details of the manipulation of variadic arguments.
    664667Since the variadic arguments are untyped, it is up to the function to interpret any data that is passed in.
     
    695698Furthermore, if the user makes a mistake, compile-time checking is typically restricted to standard format codes and their corresponding types.
    696699In general, this means that C's variadic functions are not type-safe, making them difficult to use properly.
     700\end{sloppypar}
    697701
    698702% When arguments are passed to a variadic function, they undergo \emph{default argument promotions}.
Note: See TracChangeset for help on using the changeset viewer.