From a3fefc1c3512b83072f7a6b19cbc5683b2e9cdbf Mon Sep 17 00:00:00 2001 From: Jon Rafkind Date: Wed, 14 Jul 2010 11:34:57 -0600 Subject: [PATCH] add struct example --- collects/tests/honu/struct-patterns.honu | 5 +++++ collects/tests/honu/struct-use.honu | 12 ++++++++++++ collects/tests/honu/struct.honu | 10 ++++++++++ 3 files changed, 27 insertions(+) create mode 100644 collects/tests/honu/struct-patterns.honu create mode 100644 collects/tests/honu/struct-use.honu create mode 100644 collects/tests/honu/struct.honu diff --git a/collects/tests/honu/struct-patterns.honu b/collects/tests/honu/struct-patterns.honu new file mode 100644 index 0000000000..dd7d0d03f1 --- /dev/null +++ b/collects/tests/honu/struct-patterns.honu @@ -0,0 +1,5 @@ +#lang honu + +provide structField; + +pattern structField (name_result) [name:identifier]; diff --git a/collects/tests/honu/struct-use.honu b/collects/tests/honu/struct-use.honu new file mode 100644 index 0000000000..6147e1a10e --- /dev/null +++ b/collects/tests/honu/struct-use.honu @@ -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); diff --git a/collects/tests/honu/struct.honu b/collects/tests/honu/struct.honu new file mode 100644 index 0000000000..7fa24d9236 --- /dev/null +++ b/collects/tests/honu/struct.honu @@ -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 ...)) +}