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

[REBOL] Re: Submitted, for your approval.

From: carl:cybercraft at: 28-May-2002 20:23

Hi Ed, On 28-May-02, Ed Dana wrote:
>> If Begin [ >> Symbol_Set: [ "~" "!" "@" "#" "$" "%" "&" "*" ] >> Random/seed Now >> ] >> to... >> Begin: does [ >> Symbol_Set: [ "~" "!" "@" "#" "$" "%" "&" "*" ] >> Random/seed Now >> ] > It was a good excursive in using refinements and testing the > document functionality that is built in to REBOL. >> and you can then call that with just "Begin" instead of >> "Symbols/Begin". ('does is for functions without any arguments.) > Yes, I thought about that, but noticed that there was no way to > prefix the subroutine with the parent one, at least not that I could > see. But then, I'm only on Chapter 7 of the official guide. :)
Well, you wouldn't have to prefix it if calling it from within the main function, or from outside for that matter if you hadn't made the internal functions local.
> My preferred style would have been to call the subroutine as > Symbol.Begin. Which is one of the reasons I settled for using > refinements.
My approach would be something like this... symbol: func [ "Demo function" /local begin this that and-the-other ][ begin: does [ print "Beginning..." this that and-the-other ] this: does [print "this..."] that: does [print "that..."] and-the-other: does [print "and that's all folks!"] begin ; Here's where the program starts doing something... print "The End." ] That at the console gives...
>> ? symbol
USAGE: SYMBOL DESCRIPTION: Demo function SYMBOL is a function value. And...
>> symbol
Beginning... this... that... and that's all folks! The End. Perhaps more in keeping with your style though would be to make it an object... symbol: make object! [ help: does [print "Demo object."] begin: does [ print "Beginning..." this that and-the-other end ] this: does [print "this..."] that: does [print "that..."] and-the-other: does [print "and that's all folks!"] end: does [print "The End."] ] Usage for that is...
>> symbol/help
Demo object.
>> symbol/begin
Beginning... this... that... and that's all folks! The End. and as with symbol/help and beginyou can access all the other functions within 'symbol...
>> symbol/this
this... but the functions themselves don't need the prefix to call eachother - see 'begin. Hmmm. I hope that's enlightened you and not just confused you. (: As you'll gather, REBOL's quite flexible. Not to mention fun. (; -- Carl Read