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

[REBOL] Re: Antwort: Re: WYSIWYG programming

From: jeff:rebol at: 30-Oct-2000 5:40

Howdy, Joel:
> > ... forskip has the same behavior as forall, leaving the > > series pegged ... This is by design... Some people find > > foreach pegging the series to be disconcerting, but it is > > a rather core aspect of REBOL, and it has a valid reason > > why it works that way. > > > > Please, instead of repeating "There's a reason", say what > it is!
I did in the parts you elided! :) Here's one example: foo: [1 2 3 4 5 6 7 8] forall foo [ if 1 = random length? foo [break] ] insert x 12 Forall may leave before the end. You will destroy information if you always reset the series to the head. Also, the series may not originally start at the head, so you'll need to restore it wherever it started. Add to that that the series may be changed, so the original location may no longer be a valid location, or it may be not the 'original' position. So you have a number of complicating scenarios that don't make it as simple as "reseting the series when done". So, to reiterate: 1) Preservation of information (forall may leave before completing) 2) Complexity of inputs and outputs. And of course, to understand the how come FORALL works that way: do SOURCE FORALL.
> Is there really some benefit to the user to have the block > left that way (as in my description of append vs. change), > or does this just make life easier for the implementor?
Yes. No (see above).
> We all know that forall works on a series, while foreach > extracts values from the series; that doesn't mean that the > series can't be put back where it was. (First "good > manners" rule learned in kindergarten: "Put it back when > you're through playing with it!")
Problem with changing indexes...
> It's not disconcerting... it's inconsistent and takes > time/effort to write > > forall foo [...] foo: head foo > > or (if there's a reason why foo is not at the head) > > foo2: foo forall foo [...]
A good suggestion people have offered is a refinement to forall that would reset the series when done: forall/reset series -jeff