CS 541 Lecture -*-Outline-*- * Ch. 2 Values -- Specific Questions ** Primitive Types (2.2) In C and C++, why is there no boolean type? Compare the C/C++ enumerated type to that of Pascal (or Ada) *** Cartesian Products (2.3.1) Is a record really just a cartesian product? How does it differ? *** Disjoint Unions (2.3.2) Are the unions of C and C++ secure or insecure? Why do you think they were made insecure? Can you program a secure union in C/C++? (What would that mean?) *** Mappings (2.3.3) Why should we think of arrays as mappings instead of cartesian products? What implications does an array as a mapping have for design? (Why do so few languages do it?) Is the Pascal/Ada generalization of array indices to any "discrete primitive type" worth it? Is it too hard to program yourself? (Why is it?) How can you get around that in C++? What is the role of the language as compared with the programs in this respect? What are the differences between a math function and a "function abstraction"? (Scheme procedure) -- computable, side effects (random) Would hash tables be a reasonable addition to a PL? Why or why not? *** Powersets (2.3.4) Why does Pascal support a set type? How is it limited? Why? Would C/C++ be improved by having a set type? What could be taken out of C/C++ if set were put in? (SETL supports real sets) ** Recursive Types (2.4) *** Lists (2.4.1) What does it mean to be a solution to 2.16? Why should we prefer the least solution? How do you think ML lists are implemented? Why hide the pointers? Would C/C++ be improved by hiding the pointer concept? Would Lisp/Scheme/ML be improved by making pointers explicit? (Would it make it safer?) {In ML lists do not need to be primitive types, but they are in Lisp/Scheme. Any idea why?} *** Recursive Types in General (2.4.2) This is the least fixed point construction of denotational semantics. *** Strings (2.4.3) In ML and Scheme, they're primitive. In Pascal and Ada, they're arrays of characters. In Prolog and Miranda, they're lists of characters. What are problems with the array approach? This boils down to: should the size of a string be part of its type (and hence of variables)? ** Type Systems (2.5) -- Provide a simple kind of program verification -- Allow greater expression of intent (catch own errors; catch interface errors) *** Static Type Systems Vs. Dynamic Systems (2.5.1) What is the difference between statically typed and dynamically typed? Is there any logical problem with example 2.16? (yes, what does m >= 1 mean if m is a string?) What efficiency difference does dynamic checking make? How much difference? - can optimize out many checks (self) } see OOPSLA '91 - but generally 2 times slower (at least) } What effect on quality does static/dynamic type checking have? *** Type Equivalence (2.5.2) What is the type equivalence rule in C? in C++? - for structs, name equivalence (and for classes in C++) - for all other types, structural Why would anyone want name equivalence? Is there a way to have both? Can it be under the programmer's control? *** Type Completeness (2.5.3) (Demers and Donahue, POPL 1980) Why would a language designer make some values 2nd class? What advantage is there in type completeness? Are any types in C/C++ 2nd class? Demers and Donahue take type completeness further than Watt. For example, they allow no type to have special ways to make literals (in Russell). Is this a good idea? ** Expressions (2.6) *** Aggregates (2.6.2) Does C provide aggregates for arrays? (not fully) for records? (not fully) *** Function Calls (2.6.3) What is overloading? Does C++ allow overloading? (in spades) Can a dynamically typed language have overloading? (yes) *** Conditional Expressions (2.6.4) What are the programming advantages/disadvantages of conditional expressions? *** Constant and Variable Accesses (2.6.5) Some languages (e.g., Bliss, ML) make a syntactic distinction between a variable access and the name of the variable (meaning a call). Why isn't this in more widespread usage? ------------------------- Values are a good way to make a language distinct (APL, LISP, SNOBOL, ...)