Sorry for disappointing you, but the proposed version doesn't
handle correctly the computed blocks and Break. A different
approach:
; a helper function
db: func [[throw] arg] [
either block? arg [do arg] [arg]
]
pif: func [[throw]
{polymorphic if, lazy evaluation, minimal checking}
args [block!]
] [
either unset? first args: do/next args [] [
either first args [
either logic? first args [
db first do/next second args
] [
db first args
]
] [pif second do/next second args]
]
]
; example:
for i 1 10 1 [
pif [
i = 6 head insert next copy [print break] i
]
]
Ladislav
> [EMAIL PROTECTED] wrote:
> >
> > pif: func [
> > [throw]
> > {polymorphic if with lazy evaluation and minimal checking}
> > args [block!]
> > ] [
> > while [not empty? args] [
> > args: do/next args
> > either all [
> > not unset? first args
> > first args
> > ][
> > args: first second args
> > break
> > ][
> > args: skip second args 1
> > ]
> > ]
> > if args [do args]
> > ]
> >
>
> Thanks, Eric! I've been torturing this throughout the morning,
and
> haven't gotten any surprises yet (except for the normal kinds of
> composing-at-the-keyboard typos! ;-)
>
> I did remove the first line of the function body, an assignment
to
> 'result, on the assumption that it was a typo.
>
> ORIGINALLY:
> >
> > pif: func [
> > [throw]
> > {polymorphic if with lazy evaluation and minimal checking}
> > args [block!]
> > ] [
> > result: false
> > while [not empty? args] [
> > args: do/next args
> > either all [
> ...
>
> -jn-
>
>
>