Changeset 0111dc7 for doc/rob_thesis/intro.tex
- Timestamp:
- Apr 13, 2017, 8:29:38 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 1a16e9d
- Parents:
- c87eb50
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/rob_thesis/intro.tex
rc87eb50 r0111dc7 326 326 Invariants help a programmer to reason about code correctness and prove properties of programs. 327 327 328 \begin{sloppypar} 328 329 In object-oriented programming languages, type invariants are typically established in a constructor and maintained throughout the object's lifetime. 329 330 These assertions are typically achieved through a combination of access-control modifiers and a restricted interface. 330 331 Typically, 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. 331 332 It 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} 332 334 333 335 In C, the @assert@ macro is often used to ensure invariants are true. … … 617 619 Tuples support named access and subscript access, among a few other operations. 618 620 \begin{scalacode} 619 val a = new Tuple3 [Int, String, Double](0, "Text", 2.1)// explicit creation620 val b = (6, 'a', 1.1f) // syntactic sugar forTuple3[Int, Char, Float]621 val a = new Tuple3(0, "Text", 2.1) // explicit creation 622 val b = (6, 'a', 1.1f) // syntactic sugar: Tuple3[Int, Char, Float] 621 623 val (i, _, d) = triple // extractor syntax, ignore middle element 622 624 … … 661 663 Still, @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. 662 664 665 \begin{sloppypar} 663 666 C provides manipulation of variadic arguments through the @va_list@ data type, which abstracts details of the manipulation of variadic arguments. 664 667 Since the variadic arguments are untyped, it is up to the function to interpret any data that is passed in. … … 695 698 Furthermore, if the user makes a mistake, compile-time checking is typically restricted to standard format codes and their corresponding types. 696 699 In general, this means that C's variadic functions are not type-safe, making them difficult to use properly. 700 \end{sloppypar} 697 701 698 702 % When arguments are passed to a variadic function, they undergo \emph{default argument promotions}.
Note: See TracChangeset
for help on using the changeset viewer.