mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Shallow clone (runtime function)
This commit is contained in:
parent
a453b65fd3
commit
46dfd58bda
6 changed files with 31 additions and 7 deletions
5
regression/x86only/orig/test007.log
Normal file
5
regression/x86only/orig/test007.log
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Cloning int: 5
|
||||
Cloning string: abc
|
||||
Cloning array: [1, 2, 3, 4, 5]
|
||||
Cloning sexp: A (1, 2, 3, 4, 5)
|
||||
Cloning closure: address ok, 5, 6
|
||||
14
regression/x86only/test007.expr
Normal file
14
regression/x86only/test007.expr
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
fun f (x, y) {
|
||||
fun () {x+y}
|
||||
}
|
||||
|
||||
printf ("Cloning int: %d\n", clone (5));
|
||||
printf ("Cloning string: %s\n", clone ("abc"));
|
||||
printf ("Cloning array: %s\n", clone ([1, 2, 3, 4, 5]).string);
|
||||
printf ("Cloning sexp: %s\n", clone (A (1, 2, 3, 4, 5)).string);
|
||||
|
||||
{
|
||||
local c = f (5, 6), cc = clone (c);
|
||||
|
||||
printf ("Cloning closure: address %s, %d, %d\n", if cc[0] == c[0] then "ok" else "fail" fi, c[1], c[2])
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue