Perhaps instead of with-return/loop you could structure the word as a
tail-recursive function. The way its coded right now it doesn't return
the 'obj' parameter on the stack.

If you make it tail recursive, you'll need to tell the compiler that
'quot' is a quotation, and declare it 'inline recursive':

:: delay-retry ( param quot: ( param -- result ) staller -- result )
... ; inline recursive

Slava

On Tue, Jul 28, 2009 at 7:09 PM, Darrin Thompson<[email protected]> wrote:
> On Tue, Jul 28, 2009 at 10:30 AM, Darrin Thompson<[email protected]> wrote:
>> I tried putting together a loop utility where the delay was increased
>> and iteration retried every time the iteration threw a particular
>> exception. But I was like "try this" and factor was like "unbalanced
>> branches" and then I was like "infer. doh! try this" and it was like
>> "unbalanced branches over here now". I never did get it working. Plus,
>> I was bothered by the nagging idea that there was probably an
>> important utility somewhere I was missing.
>>
>
> http://paste.factorcode.org/paste?id=803
>
> I got this working. Here's the relevant bit:
>
> ! Locals, loops, and continuations all in one place.
> ! Avert your eyes.
> :: delay-retry ( param quot staller -- obj )
>    [
>        [
>            staller stall
>            [ param quot call return ]
>            [ dup need-to-slow-down? [ drop ] [ rethrow ] if
>              staller slow-down
>            ] recover
>            t
>        ] loop
>    ] with-return ; inline
>
> Are you ashamed for me?
>
> --
> Darrin
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to