Hi rebolers,

being busy with some dialecting I bumped into a kind of context 
(variable scope) problem.
Here follows a small example:

==============================================================================================================================================
REBOL []

dc: make object! [
    rule: [set num1 number! '+ set num2 number! (print num1 + num2 res: 
insert tail res (num1 + num2))]
    calc: func [
        input [block!]
        /local
            res
            num1
            num2
    ][
        res: copy []
        if not parse input rule [
            res: "Bad input!"
        ]
        print head res
    ]
]
   
dc/calc [5 + 2]

halt
==============================================================================================================================================

When executing dc/calc [5 + 2] it says:
    7
    ** Script Error: res has no value
    ** Where: calc
    ** Near: res: insert tail res (num1 + num2)

Which means that variables num1 and num2 are having a value, added and 
printed (7),
but res has no value.

However res is defined in dc/calc and is being initialized properly 
right before executing the parse.

When I define res at the same level as I did rule and not within clc, 
everything works fine.

Any hints to improve my understanding?

TIA

Kind regards,
    Arie
-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to