[Gd-chatter] r11083 - trunk/fundev/sources/collections
agent at gwydiondylan.org
agent at gwydiondylan.org
Wed Dec 20 08:54:00 CET 2006
Author: agent
Date: Wed Dec 20 08:53:58 2006
New Revision: 11083
Added:
trunk/fundev/sources/collections/table-macros.dylan (contents, props changed)
Modified:
trunk/fundev/sources/collections/collections.lid
trunk/fundev/sources/collections/library.dylan
Log:
Bug: 7339
Checked in table macro into table-extensions module.
Modified: trunk/fundev/sources/collections/collections.lid
==============================================================================
--- trunk/fundev/sources/collections/collections.lid (original)
+++ trunk/fundev/sources/collections/collections.lid Wed Dec 20 08:53:58 2006
@@ -8,6 +8,7 @@
collectors-macros
collectors
plists
+ table-macros
Other-Files: Open-Source-License.txt
Major-Version: 2
Minor-Version: 1
Modified: trunk/fundev/sources/collections/library.dylan
==============================================================================
--- trunk/fundev/sources/collections/library.dylan (original)
+++ trunk/fundev/sources/collections/library.dylan Wed Dec 20 08:53:58 2006
@@ -72,6 +72,7 @@
end module set;
define module table-extensions
+ use dylan;
use dylan-extensions,
import: { <string-table>, <hash-state>,
collection-hash, sequence-hash,
@@ -80,9 +81,10 @@
string-hash,
case-insensitive-string-hash,
case-insensitive-equal,
- remove-all-keys!,
- merge-hash-ids },
+ remove-all-keys!,
+ merge-hash-ids },
export: all;
+ export \table;
end module table-extensions;
define module collections-internals
Added: trunk/fundev/sources/collections/table-macros.dylan
==============================================================================
--- (empty file)
+++ trunk/fundev/sources/collections/table-macros.dylan Wed Dec 20 08:53:58 2006
@@ -0,0 +1,27 @@
+Module: table-extensions
+Synopsis: The table constructor macro, et al.
+Author: Dustin Voss
+Copyright: Copyright (c) 2006 Dustin Voss.
+ All rights reserved.
+License: Functional Objects Library Public License Version 1.0
+Dual-license: GNU Lesser General Public License
+Warranty: Distributed WITHOUT WARRANTY OF ANY KIND
+
+// Table constructor. Syntax:
+// let my-table = table("red"=>"stop", "green"=>"go");
+// let my-table = table(<string-table>, "red"=>"stop", "green"=>"go");
+//
+define macro table
+
+ // Matches when optional class included.
+ { table(?table-class:expression, ?table-contents) }
+ => { let ht = make(?table-class); ?table-contents; ht; }
+
+ // Matches without optional class.
+ { table(?rest:*) } => { table(<table>, ?rest); }
+
+ table-contents:
+ { } => { }
+ { ?key:expression => ?value:expression, ... }
+ => { ht[?key] := ?value; ... }
+end macro table;
More information about the chatter
mailing list