return from nested define/loops
Posted: Thu Aug 12, 2004 10:07 pm
Hi Anyone,
basicly a simple issue but i cant get it working...
(last resort of help was using catch and throw but thats not 100%
what i want)
I would like to have a nested (define...) to break/return at
a certain point and then return the value to the main (define..)
As in the following example where (one) should return nil of true
from (four) or from (three)
;--------
(define (one)
(define (two)
(unless (someone)
(define (three) (unless (here?) nil true)))
(define (four) (unless (this-is-it) nil true))))
)
(unless (one) "jep" "no")
;--------
I like the way of having a 'break inside any (define) that always
returns to main-(define) weather its a loop or a (define) itself, a break/return should stop at current execution point and return value...but i can only find the way of using throw and catch but that is not always working and is generaly creating more code then needed...
(assuming 'break is not used for debug/tracing)
;--------
(define (one)
(define (two)
(unless (someone)
(define (three) (unless (here?) (break nil) (break true))))
(define (four) (unless (this-is-it) (break nil) (break true)))))
)
(unless (one) "jep" "no")
;--------
Any idea's?
Norman.
basicly a simple issue but i cant get it working...
(last resort of help was using catch and throw but thats not 100%
what i want)
I would like to have a nested (define...) to break/return at
a certain point and then return the value to the main (define..)
As in the following example where (one) should return nil of true
from (four) or from (three)
;--------
(define (one)
(define (two)
(unless (someone)
(define (three) (unless (here?) nil true)))
(define (four) (unless (this-is-it) nil true))))
)
(unless (one) "jep" "no")
;--------
I like the way of having a 'break inside any (define) that always
returns to main-(define) weather its a loop or a (define) itself, a break/return should stop at current execution point and return value...but i can only find the way of using throw and catch but that is not always working and is generaly creating more code then needed...
(assuming 'break is not used for debug/tracing)
;--------
(define (one)
(define (two)
(unless (someone)
(define (three) (unless (here?) (break nil) (break true))))
(define (four) (unless (this-is-it) (break nil) (break true)))))
)
(unless (one) "jep" "no")
;--------
Any idea's?
Norman.