C Block Trick

From VpriWiki

Jump to: navigation, search

Within a C block nested in a Pepsi block, you might want to access a variable from an outer scope. This is not directly possible, but there exists a simple workaround to achieve the desired result:


[
    | a |
    a := 1.
    1 timesRepeat: [
        | blockA |
        blockA := a.
        { printf ("a: %p\n", v_blockA); }.
    ].
]