This repository was archived by the owner on May 13, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTypes.org
More file actions
45 lines (35 loc) · 1.42 KB
/
Copy pathTypes.org
File metadata and controls
45 lines (35 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
* 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:
#+INCLUDE: "src/SimpleTypes.gf" src gf
*** Enumeration types
- The only kind of enumeration types in GF are the so-called *param* types
- Example:
#+INCLUDE: "src/Param.gf" src gf
*** 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:
#+INCLUDE: "src/Compound.gf" src gf
- 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:
#+INCLUDE: "src/Functions.gf" src gf