add struct example
This commit is contained in:
parent
9a984fcc2b
commit
a3fefc1c35
5
collects/tests/honu/struct-patterns.honu
Normal file
5
collects/tests/honu/struct-patterns.honu
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#lang honu
|
||||||
|
|
||||||
|
provide structField;
|
||||||
|
|
||||||
|
pattern structField (name_result) [name:identifier];
|
12
collects/tests/honu/struct-use.honu
Normal file
12
collects/tests/honu/struct-use.honu
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#lang honu
|
||||||
|
|
||||||
|
require "struct.honu";
|
||||||
|
|
||||||
|
struct foo {a b c};
|
||||||
|
|
||||||
|
z = foo(1, 2, 3);
|
||||||
|
y = 3;
|
||||||
|
y = 9;
|
||||||
|
// x = foo(1, 2, 3);
|
||||||
|
|
||||||
|
display(z.a);
|
10
collects/tests/honu/struct.honu
Normal file
10
collects/tests/honu/struct.honu
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#lang honu
|
||||||
|
|
||||||
|
require (forSyntax "struct-patterns.honu");
|
||||||
|
|
||||||
|
provide struct;
|
||||||
|
macro struct () {
|
||||||
|
_ name {field:structField ...} ;
|
||||||
|
} {
|
||||||
|
schemeSyntax#sx(honu-struct name (field_name_result ...))
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user