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

[REBOL] Re: 'do vs 'reduce

From: andreas:bolka:gmx at: 6-Jan-2004 22:08

Tuesday, January 6, 2004, 5:24:10 AM, Volker wrote:
> Am Montag 05 Januar 2004 17:59 schrieb Gregg Irwin: >> Hi Andreas, >> >> AB> i was wondering if, letting refinements and non-block! parameters >> AB> aside, 'do is really just a "last reduce", in other words, if (a >> AB> simplified) do could be precisely expressed as: >> >> AB> do: func [ bl [block!] ] [ last reduce bl ] >> >> Well, both cause evaluation. If LOAD were used (thinking about binding >> issues), and having not done any tests, my feeling is that you're >> probably right. Knowing how Carl likes to build things, I can't >> imagine he'd want two separate evaluators in REBOL. :) >> > similar, but > 1) [do %file.r] <> [reducce %file.r]
that's what i meant with "non-block!" parameters. there are similar differences when you pass an url! or string! as parameter.
> 2) 'do can give arguments to expressions. the only function with a dynamic > number of arguments:
!>>> reduce func[a][a * a] 5
> == 5 ; reduce-result is thrown away
!>>> do func[a][a * a] 5
> == 25 ; 5 is past to func by do. 'do fetches actually 2 arguments in this > case.
same stuff here. not a block! is passed, and do behaves "specially" (apply/invoke style) when a function! is passed as first parameter. -- Best regards, Andreas