Semantics

Cards (55)

  • Semantics
    Meaning, which can be subtle and open to interpretation
  • Ways to specify semantics
    • Language reference manual
    • Defining translator
    • Formal definition
  • Language reference manual
    • Most common way to specify semantics
    • Suffer from lack of precision inherent in natural language descriptions
    • May have omissions and ambiguities
  • Defining translator
    • Advantage is that questions about a language can be answered by experiment
  • Formal definition
    • Precise, but complex and abstract, and require study to understand
    • Different formal methods available, with choice depending on intended use
  • Attributes
    Properties or characteristics associated with a name
  • Binding
    The process of associating an attribute with a name
  • Semantic functions
    Functions that define the meaning of language constructs
  • Static binding
    Binding that occurs prior to execution
  • Dynamic binding
    Binding that occurs during execution
  • Static attribute
    Attribute that is bound statically
  • Dynamic attribute
    Attribute that is bound dynamically
  • Declarations
    Principal method for establishing bindings
  • Definitions
    Declarations that bind all potential attributes
  • Declarations
    Declarations that only partially specify attributes
  • Block
    Language construct consisting of a sequence of declarations followed by a sequence of statements
  • Local declarations
    Declarations associated with a specific block
  • Non-local declarations
    Declarations in surrounding blocks or global declarations
  • Scope
    Region of the program over which a binding is maintained
  • Lexical scope
    Scope rule where scope follows the structure of the blocks as they appear in the written code
  • Symbol table
    Data structure that supports insertion, lookup, and deletion of names with associated attributes, representing the bindings in declarations
  • Scope analysis
    Process of adding declarations to the symbol table on entry into a block and removing them on exit
  • Static environment
    Environment constructed at load time
  • Dynamic environment
    Environment constructed at execution time
  • Variable
    Object whose stored value can change during execution
  • Assignment by sharing
    Assignment where locations are copied instead of values
  • Assignment by cloning
    Assignment where a new location is allocated, the value is copied, and the variable is bound to the new location
  • Constant
    Language entity with a fixed value for the duration of its existence in a program
  • Static constant
    Constant whose value can be computed prior to execution
  • Dynamic constant
    Constant whose value can only be computed during execution
  • In C, load-time constants cannot be defined because of a separate rule restricting initial values of global variables to a narrow subset of compile-time expressions
  • In any programming language, it is the use of names or identifiers, to denote language entities or constructs
    Fundamental abstraction mechanism
  • In addition to names, a description of the semantics of most programming languages includes the concepts of location and value
    TRUE
  • Values
    Any storable quantities, such as the integers, the reals, or even array
  • Locations
    Places values can be stored. Like addresses in the memory
  • The meaning of a name is determined by the properties or ______
    attributes
  • In some languages, constructs that cause values to be bound to names are in fact called bindings rather than declarations
  • ML Code Examples
    let val x = 2; val y = 3 in x + y
  • Bindings can be determined by a declaration either implicitly or explicitly
  • The notion of blocks containing declarations began with Algol60, and all Algol descendants exhibit this block structure in various ways