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

[REBOL] Re: Submitted, for your approval.

From: edanaii:cox at: 27-May-2002 8:11

Carl Read wrote:
> Hi Ed, > > It works fine, though I was a bit confused by the Matched and Placed > numbering to begin with, not realizing that once something was placed > it was no longer recorded as matched. "Misplaced" might've been a > better term. (; > > As to your code: Well you've got me wondering whether having a > function call it's own refinements like that instead of having > seperate functions for those routines is a good or bad thing... I > think it probably is bad, (mainly due to a performance issue with the > amount of code you have to get through to get to the last "if > whatever..."), but as you've found out, it does work. Note however > that it only works because the words you create in the function are > global, not local. If you'd tried to make Symbol_Set local by > having... > > /local Symbol_Set >
Yep. I realize that. Next revision will likely include passing and returning parameters.
> in the function's first block you'd get an error when calling the > function with any refinement other than /begin. With REBOL > functions, words defined in the body of the function are made global > by default, not local. This is because "it's better for beginners" > apparently. (: > > An alternative approach to using refinements would've been to have > them as functions within your function. ie, just change... > > 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. :) My preferred style would have been to call the subroutine as Symbol.Begin. Which is one of the reasons I settled for using refinements. As I said, this is a learning excursive for me. Sometimes the best way to learn is to make all the mistakes you can up front. Saves time by not making them later. :) I'll continue to revise things as I learn more.
> Otherwise though, you're learning fast! It's good and tidy code on > the whole. >
Thanks. After programming for 26 years, I sure hope my code is tidy. :) -- Sincerely, | Ed Dana | Life's but a knife's edge, anyway. Sooner or later Software Developer | people slip and get cut. 1Ghz Athlon Amiga | -- Larry McMurtry, Streets of Laredo