Rename the language from Dino to Rex
Files use .rex, the command is rex, and the crate, runtime prefixes, docs, editor files and examples all use the new name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2f44f09b6a
commit
7cf9727bcd
94 files changed
+858
-858
No files matched your search
@@ -0,0 +1,49 @@
|
||||
struct Counter {
|
||||
n: int
|
||||
|
||||
func bump(): int {
|
||||
n += 1
|
||||
return n
|
||||
}
|
||||
}
|
||||
|
||||
struct Pair {
|
||||
left: Counter
|
||||
right: Counter
|
||||
}
|
||||
|
||||
func bump_copy(c: Counter): int {
|
||||
return c.bump()
|
||||
}
|
||||
|
||||
func main() {
|
||||
// assignment copies
|
||||
var a = Counter{1}
|
||||
var b = a
|
||||
b.n = 100
|
||||
print(a.n, b.n)
|
||||
|
||||
// passing to a function copies
|
||||
print(bump_copy(a), a.n)
|
||||
|
||||
// methods change the variable they are called on
|
||||
a.bump()
|
||||
a.bump()
|
||||
print(a.n)
|
||||
|
||||
// nested structs are copied as a whole
|
||||
var p = Pair{Counter{10}, Counter{20}}
|
||||
var q = p
|
||||
q.left.bump()
|
||||
p.right.bump()
|
||||
p.right.bump()
|
||||
print(p.left.n, p.right.n, q.left.n, q.right.n)
|
||||
|
||||
// reading before a later call in the same expression: the earlier read wins
|
||||
var c = Counter{0}
|
||||
print(c.n, c.bump(), c.n)
|
||||
|
||||
// constants can be read and used with non-mutating code
|
||||
const k = Counter{7}
|
||||
print(k.n)
|
||||
}
|
||||
Reference in new issue
Block a user