1 / 14

Types and Related Issues

Types and Related Issues. Bindings. Bindings. Are factors that characterize objects name location value type scope lifetime. Bindings (continued). Can be static or dynamic Can occur at many different times: language design operator symbols to operations language implementation

jock
Download Presentation

Types and Related Issues

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Types and Related Issues • Bindings

  2. Bindings • Are factors that characterize objects • name • location • value • type • scope • lifetime

  3. Bindings (continued) • Can be static or dynamic • Can occur at many different times: • language design • operator symbols to operations • language implementation • range of values for integers • compile • variable to type • link • call to library subprogram • load • static variables to memory cells • run • value to variable

  4. Names

  5. Names • Format • length • character set • case • reserved word or keyword for meaningful names in the language? • Aliasing

  6. Location

  7. Location • Static • Stack dynamic • Explicit heap dynamic • Implicit heap dynamic • rare, used in APL and Algol-68

  8. Type

  9. Type • Primitive or complex • Usually bound statically • but can be dynamic in LISP, APL, SNOBOL • Coercion or casting • Strong typing • language “always detects type errors” • Name compatibility or structure compatibility • name: same declaration or same type name • easier to implement but restrictive • structure: same internal structure • may not be strict enough

  10. Type (continued) • Most languages use a combination of equivalence methods • Pascal: usually structure, but in some cases name is used (formal parameters) • C: structure, except for records • C++: name • Ada: restricted form of name • derived types allow types with the same structure to be different • type celcius is new real; type fahrenheit is new real; • subtype allows types to be compatible even with different names • subtype digit is INTEGER range 0..9;

  11. Scope

  12. Scope • Range of statements in a program when a name can be referenced (is visible) • Controlled by subprograms, compound statements • Static • most languages • Dynamic • APL, SNOBOL, some LISPs • means no compile-time type checking of non-local objects

  13. Lifetime

  14. Period when data object is allocated memory • Can be different than scope • hole in scope • static variables • invoking external subprogram

More Related