Skip to content

Latest commit

 

History

History
45 lines (35 loc) · 1.42 KB

File metadata and controls

45 lines (35 loc) · 1.42 KB

Types

  • GF is statically typed: You cannot say something like … a = 3 ; a = “Foo” ; …
  • GF makes a distinction into abstract syntax/concrete syntax as well as resource modules

Basic types

  • GF also support some basic types
    • Python has strings (called `str`). GF has strings (called `Str`).
    • Python has integers (called `int`). GF has integers (called `Int`).
    • Python has floating-point numbers (called `float`). GF’s are called `Float`.
  • These types can be used in resource modules and concrete syntax files
  • Strings vs. String tuples
    • Substrings can be concatenated with +
    • Sentences in GF are kind of lists of strings, ++ concatenates lists of strings
  • Example:

Enumeration types

  • The only kind of enumeration types in GF are the so-called param types
  • Example:

Compound types

  • GF has three kinds of compound types, tables, records and tuples, Python has dictionaries, tuples and lists
  • GF does not really have lists
  • Keys in tables usually are *param*s and keys in records are literal identifier
  • Example:
  • To select values from tables the ! operator is used, to select from records the . operator
  • Tuples are special cases of records

Functions

  • GF supports both regular functions and anonymous functions
  • Example: