Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,13 @@
|
|||
(define B (box 42))
|
||||
→ B ;; box reference
|
||||
(unbox B)
|
||||
→ 42 ;; box contents
|
||||
|
||||
;; sets new value for box contents
|
||||
(define ( change-by-ref abox avalue)
|
||||
(set-box! abox avalue) )
|
||||
|
||||
(change-by-ref B 666)
|
||||
→ #[box 666]
|
||||
(unbox B)
|
||||
→ 666
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Type Cat
|
||||
name As String
|
||||
age As Integer
|
||||
End Type
|
||||
|
||||
Type CatInfoType As Sub (As Cat Ptr)
|
||||
|
||||
Sub printCatInfo(c As Cat Ptr)
|
||||
Print "Name "; c->name, "Age"; c-> age
|
||||
Print
|
||||
End Sub
|
||||
|
||||
' create Cat object on heap and store a pointer to it
|
||||
Dim c As Cat Ptr = New Cat
|
||||
|
||||
' set fields using the pointer and the "crow's foot" operator
|
||||
c->name = "Fluffy"
|
||||
c->age = 9
|
||||
|
||||
' print them out through a procedure pointer
|
||||
Dim cit As CatInfoType = ProcPtr(printCatInfo)
|
||||
cit(c)
|
||||
|
||||
Delete c
|
||||
c = 0
|
||||
|
||||
Dim i As Integer = 3
|
||||
' create an integer pointer variable and set it to the address of 'i'
|
||||
Dim pi As Integer Ptr = @i
|
||||
|
||||
'change the variable through the pointer
|
||||
*pi = 4
|
||||
|
||||
'print out the result
|
||||
print "i ="; *pi
|
||||
|
||||
'create a reference to the variable i
|
||||
Dim ByRef As Integer j = i
|
||||
|
||||
' set j (and hence i) to a new value
|
||||
j = 5
|
||||
|
||||
' print them out
|
||||
Print "i ="; i, "j ="; j
|
||||
Sleep
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
type Foo = ref object
|
||||
x, y: float
|
||||
|
||||
var f: Foo
|
||||
new f
|
||||
|
|
@ -0,0 +1 @@
|
|||
echo f[]
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
echo f[].x
|
||||
f[].y = 12
|
||||
echo f.y
|
||||
f.x = 13.5
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
var x = 3
|
||||
var p = addr x
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
echo p[]
|
||||
p[] = 42
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
var y = 12
|
||||
p = addr y
|
||||
|
|
@ -0,0 +1 @@
|
|||
p = nil
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
func assign2ref(ref, value) {
|
||||
*ref = value;
|
||||
}
|
||||
|
||||
var x = 10;
|
||||
assign2ref(\x, 20);
|
||||
say x; # x is now 20
|
||||
Loading…
Add table
Add a link
Reference in a new issue