Hi Andrew,
In state.r, I think you can save yourself the lines
> if set-word? :Item [
> Item: mold :Item
> replace Item ":" ""
> Item: to-word Item
since you can directly convert a set-word type to a word using make word!
or to word! (to-word will fail):
>> a: [word:]
== [word:]
>> item: first a
== word:
>> set-word? :item
== true
to word! and make word! work:
>> new-word: to word! :item
== word
>> new-word
== word
>> new-word: make word! :item
== word
>> new-word
== word
whereas to-word fails:
>> new-word: to-word :item
** Script Error: word needs a value.
** Where: to word! value
At 03:00 AM 1/25/00 -0800, you wrote:
>Still feeling inspired, here's my state machine _dialect_ and a general
>purpose _queue_ for REBOL. First, %Queue.r:
>
>Queue!: func [/Initial Size [integer!]][
> all [not Initial Size: 10]
> make object! [
> In: func ['Word [word!] Value /Arg2 Value2][
> append _Queue Word
> append/only _Queue reduce Value
> if Arg2 [append/only _Queue reduce Value2]
> ]
> _Queue: make block! Size
> Out: func [][
> do _Queue
> Clear
> ]
> Clear: func [][
> system/words/clear _Queue
> ]
> ]
> ]
>
>
>Then %State.r:
>
>State!: func [][
> make object! [
> _State: no
> State: func [][_State]
> Start: func ['Initial [word!]][
> _State: Initial
> ]
> Stop: func [][_State: no]
> Run!: func [][
> while [_State][
> try [do State true]
> ]
> ]
> Goto: func ['Next [word!]][
> _State: Next
> ]
> Dialect: function [Dialect [block!]][Locals][
> Locals: make block! 10
> foreach Item Dialect [
> if set-word? :Item [
> Item: mold :Item
> replace Item ":" ""
> Item: to-word Item
> if not found? find Locals Item [
> append Locals Item
> ]
> ]
> ]
> use Locals bind/copy Dialect '_State
> ]
> ]
> ]
>
>State: State!
>
>do %Queue.r
>
>State/Dialect [
> Queue: Queue!
> then: now/time
> na: 0
> a: [
> na: na + 1
> Queue/In print ["na:" na]
> Goto b
> ]
> nb: 0
> b: [
> nb: nb + 1
> Queue/In print ["nb:" nb]
> either nb < 10 [
> Goto a
> ][
> Stop
> ]
> ]
> Start a
> Run!
> Queue/In print (now/time - then)
> Queue/Out
> na ; return the counter.
> ]
>
>They're also attached.
>
>Andrew Martin
>Who's sure that 'parse-block will improve this...
>ICQ: 26227169
>[EMAIL PROTECTED]
>http://members.xoom.com/AndrewMartin/
>-><-
>
>
>
>Attachment Converted: "c:\eudora\attach\Queue.r"
>
>Attachment Converted: "c:\eudora\attach\State.r"
>
;- Elan >> [: - )]