Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: how to export a function from a context?

From: tim:johnsons-web at: 30-Dec-2003 18:35

* [Patrick--Philipot--laposte--net] <[Patrick--Philipot--laposte--net]> [031230 12:11]:
> Hi List > > As I was reading "Make-doc.r" from Carl Sassenrath, I came upon a > construction I had not noticed before. Or perhaps, I had not noticed > how important it was before. > > Nothing new for a lot of you, but ... I think it's cool to see some > Rebol code once and a while on this list. > > 8< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > Rebol [ > date: 30-12-2003 > purpose: { FAQ > Q - "how to export a function from a context?" > A - "by using SET. SET always define a global word" } > ] > > private-room: context [ > a: b: 2 > set 'public-fn func [][print [a]] > ]
Hiya Patrick: Here's a different approach: Remove the assignment to 'private-room Now you have context [ a: b: 2 set 'public-fn func [][print [a]] ] At this time, 'public-fn is still 'public' but 'a, 'b are now 'hidden', inaccessible from the outside world. but of course, you can't make copies of the function. tj
> a: "Some text" > > print [a] ; ==Some text > public-fn ; 2 > > 8< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > And finally, I will borrow my whishes from the new year from Freddie > Mercury. > > "The one thing we're all waiting for is peace on earth - an end > to war. It's a miracle we need - the miracle" > > -- > Best regards, > Patrick > > -- > To unsubscribe from this list, just send an email to > [rebol-request--rebol--com] with unsubscribe as the subject.
-- Tim Johnson <[tim--johnsons-web--com]> http://www.alaska-internet-solutions.com<