[REBOL] Return From Middle Of Script? Re:(2)

2000-06-26 Thread Galt_Barber




There are some programs that actually work quite nicely
with goto or multiple exits, and the code is actually much easier to read.
I am not saying that they are good to use all the time, but I can make
a pretty strong case that they are not always the inferior solution.






[REBOL] Return From Middle Of Script? Re:(2)

2000-06-23 Thread leshert

Why not something like this:

-- start doer.r: --
REBOL []

do-thing: func [] [
; do your script here
return 1
]

do-thing
--- end doer.r 

Then you can just

>> do %doer.r
== 1
-- 
Tim Lesher
[EMAIL PROTECTED]


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 23, 2000 13:08
To: [EMAIL PROTECTED]
Subject: [REBOL] Return From Middle Of Script? Re:


Hi,

> I have a script that 'do(es) another script.
> The called script assembles a string and returns
> it to the caller by placing the string word as
> the last line in the script.  Fine.
> 
> But the called script has numerous places where
> an error can occur and I would like to return
> a partially assembled string at that point.
> How to do this?  'return only works in a function
> and 'halt doesn't seem to allow the script to return
> the last evaluated argument.
> 
> In psuedocode what I want is:
> 
> if (some condition)
> [
> return "string1"
> ]
> 
> but I obviously can't use 'return and the following:
> 
> if (some condition)
> [
> "string1"
> halt
> ]
> 
> does not return "string1" to the caller.
> 
> There doesn't appear to be a 'goto call where I can just
> go to the end of the script either.
> 
> How are you guys accomplishing this sort of thing?  (And more
> philosophically - why can't you use 'return in a script?)
> 
> TIA,
> 
> Rodney
> 
> 

you can try:

result: catch [
do script
]

and in script:

if some-condition [
throw string1
]