rules maybe like this (full code below)

; example
gui: make object! [
    a: rule-var "a0"
    b: rule-var "b0"
    c: rule-var "c0"
    rule [ a b ] func [][ trace-state "one of [a b] changed"         c/set 
'c-by-rule-ab ]
    rule[ c ] func[][ trace-state "c changed" ]

    trace-state: func[id][print ["rule[" id "]"       a/get b/get c/get]] ; 
tool
]

I prefer the browser-like approach of Rebol/View: 
one page per action, create a new page after each action. No hidden 
Recursion, no bugs.

In einer eMail vom 17.02.00 04:39:17 (MEZ) Mitteleurop�ische Zeit schreibt 
[EMAIL PROTECTED]:

> Those interested in new and unusual programming constructs, take a look at
>  R++ from AT&T, where Bjarne Stroustrup, the inventor of C++, works. Here's
>  the link:
>          http://www.research.att.com/sw/tools/r++/
>  
>  <Quote>
>  R++ extends the C++ language with a single new programming construct -- the
>  rule. In addition to data-members and member functions, R++ adds a new kind
>  of member to C++ classes namely "member rules". A rule is a statement
>  composed of a condition and an action that specifies what to do when the
>  condition becomes true. Whenever some program data changes, rules whose
>  conditions involve that data are examined, and if a rule's condition
>  evaluates to true, its action is executed. The action may of course modify
>  data and therefore trigger other rules. Currently R++ is implemented as a
>  pre-processor. It translates R++ rules into C++ code.
>  </Quote>
>  
>  What would this look like in REBOL?
>  
>  Andrew Martin
>  ICQ: 26227169
>  http://members.xoom.com/AndrewMartin/
>  

[REBOL[]

;
; tools: rule-var rule
;
rule-var: func [ init-value ][
    make object! [
        value: init-value
        listeners: copy []
        set: func [ new-value ] [ 
            value: new-value
            foreach here listeners  [ here ]
        ]
        get: func[][value]
        listen: func[ listener ][ append listeners :listener ]
    ]
]
rule: function[vars method][sum vals][
    foreach here vars [
        val: get here
        val/listen get 'method
    ]
]
;
; example
;
gui: make object! [
    a: rule-var "a0"
    b: rule-var "b0"
    c: rule-var "c0"
    rule [ a b ] func [][ trace-state "one of [a b] changed"         c/set 
'c-by-rule-ab ]
    rule[ c ] func[][ trace-state "c changed" ]

    trace-state: func[id][print ["rule[" id "]"       a/get b/get c/get]] ; 
tool
]

print "set a"
gui/a/set 'a1
print "set b"
gui/b/set 'b1
print "set c"
gui/c/set 'c1
print "done"
]




Gruss Volker

Reply via email to