[REBOL] Re: Translate this code into real Rebol?
From: brett:codeconscious at: 24-Jan-2002 15:18
Hi Joel,
I know your message was directed to Jeff and I look forward to his answer.
> Any thoughts on how to get the benefits of inner functions
> (nice "packaging" and communication of ideas, maximum locality,
> minimizing global namespace impact, shared context) without
> the overhead of redefinition on every use?
I don't pretend to have a good answer, but thought I'd share
this; what about a defining a context (object!)?
make context [fibohelp: none] [
set 'fibonacci func [n [integer!] /test][
fibohelp: func [n [integer!] /local a b] [
a: 0 b: 1
while [n > 0] [a: (b: b + a) - a n: n - 1]
print ["by the way the value of test is:" mold test]
a
]
either all [negative? n even? n] [
- fibohelp abs n
] [
fibohelp abs n
]
]
]
The good thing is Fibohelp can utilise words from Fibonacci's namespace. The
bad thing is
if you wanted Fibonacci in an object of itself. The assumed thing is that
there is no redefinition
occurring every call.
Brett.