TupleSpace Dialect
[1/5] from: al::bri::xtra::co::nz at: 13-Jun-2002 21:09
Anyone written a TupleSpace dialect?
I'm thinking of writing one,...
Andrew Martin
RebolSpaces...
ICQ: 26227169 http://valley.150m.com/
[2/5] from: oliva:david:seznam:cz at: 14-Jun-2002 10:49
Hello Andrew,
Thursday, June 13, 2002, 11:09:02 AM, you wrote:
AM> Anyone written a TupleSpace dialect?
AM> I'm thinking of writing one,...
And what is it?
[3/5] from: al:bri:xtra at: 17-Jun-2002 16:21
> > Anyone written a TupleSpace dialect?
> > I'm thinking of writing one,...
> And what is it?
Something like:
http://www.linuxjournal.com/article.php?sid=2376
but using Rebol values.
Imagine screens in HTML and Rebol/View.
There's more here:
http://www.hsdi.com/qddb/documentation/
My equivalent to the Linux Journal's example is something like:
; Schema
Street string!
City string!
State "Zip Code" issue!
some Apartment [
AptNumber "Apartment Number" integer!
Rented logic! false
Lease [
Begin date!
End date!
]
some Person [
First string!
Middle string!
Last string!
ID string!
PrimaryRenter "Primary Renter" logic! true
]
some Comments string!
]
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[4/5] from: brett:codeconscious at: 17-Jun-2002 15:39
> > > Anyone written a TupleSpace dialect?
> > > I'm thinking of writing one,...
>
> > And what is it?
>
> Something like:
> http://www.linuxjournal.com/article.php?sid=2376
> but using Rebol values.
Looks useful :^)
Brett.
[5/5] from: al:bri:xtra at: 17-Jun-2002 21:52
After some work, I've got this function which can interpret the schema and
data in succeeding rows/block, checking that the data matches the schema.
make object! [
Row: make block! 100
Stack: make block! 100
Push_Row: does [
push/only Stack Row
Row: make block! 10
]
Type: none
Column: [
word! opt string! [
[
'logic! opt ['false | 'true] (
append/only Row ['false | 'true]
)
]
| set Type [
'string! opt string!
| 'issue! opt issue!
| 'integer! opt integer!
| 'decimal! opt decimal!
| 'money! opt money!
| 'date! opt date!
| 'time! opt time!
| 'url! opt url!
| 'file! opt file!
] (
append Row Type
)
]
]
Name_Block: [
word! (Push_Row) into Header (
Row: compose/deep [(pop Stack) into [(Row)]]
)
]
Header: [
some [
[
'some (Push_Row) [Column | Name_Block] (
Row: compose/deep [(pop Stack) some [(Row)]]
)
]
| Column | Name_Block
]
end
]
set 'Tree func [Data [block!]] [
parse Data [
into Header
any [into Row]
end
]
]
]
Which can understand this block of Schema and Data:
Sample: [
; Schema
[
Street string!
City string!
State string!
ZipCode "Zip Code" issue!
some Apartment [
AptNumber "Apartment Number" integer!
Rented logic! false
Lease [
Begin date!
End date!
]
some Person [
First string!
Middle string!
Last string!
ID integer!
PrimaryRenter "Primary Renter" logic! true
]
some Comments string!
]
Url url! http://www.rebol.com
Money money! $100.00
Time time! 12:00
Decimal decimal! 123.45
File file! %/C/Rebol/Core/Rebol.exe
]
; Data
[
"65 Milton Road" "Napier" "NZ" #4001 [
123 true [12/March/2002 23/April/2003]
["Andrew" "John" "Martin" 1001 true]
"He's me!" "Are you sure?" "Yes!" "Banana"
]
http://valley.150m.com $123 12:34:56 12.345 %/C/Rebol/View/Rebol.exe
]
]
And these stack functions are needed as well:
Pop: function [
"Returns the first value in a series and removes it from the series."
Stack [series! port! bitset!] "Series at point to pop from."
][
Value
][
Value: pick Stack 1
remove Stack
:Value
]
Push: func [
"Inserts a value into a series and returns the series head."
Stack [series! port! bitset!] "Series at point to insert."
Value [any-type!] /Only "The value to insert."
][
head either Only [
insert/only Stack :Value
][
insert Stack :Value
]
]
This is some test code for the above:
do %Tree.r
probe Tree Sample
The 'Tree function works by 'parse-ing the schema, and generating
appropriate 'parse rules for the subsequent data blocks.
Comments, suggestions, improvements etc all welcome.
Andrew Martin
ICQ: 26227169 http://valley.150m.com/