REBOL3 tracker
  0.9.12 beta
Ticket #0002250 User: anonymous


Previous Next
Short URL:
TypeWish Statussubmitted Date15-Dec-2015 09:01
Versionr3 master CategoryUnspecified Submitted byabolka
PlatformAll Severityminor Prioritynormal

Summary A plain, explicit QUIT from nested scripts should return UNSET! to the calling script, not 0
Description Currently, in Rebol 3, when using one Rebol script to run another via DO, the called script can return Rebol values to the calling script.

In the simplest case, the returned value is the last evaluated value in the inner script, similar to the implied return in functions:

>> do {10 + 20 3 + 4}
== 7 ;; Good

(NB: I use strings instead of files in these examples. Currently code from strings is treated like a script, just as code in a file. If that bothers you, imagine `do %foo.r` instead, with the string as foo.r's content.)

In another common case, scripts can quit early, by using QUIT. If they want to return a value explicitly, the can do so via QUIT/return:

>> do {quit/return 42}
== 42 ;; Good

If QUIT/return returns to another Rebol script, the full range of Rebol values can be passed along. If QUIT/return returns out of the top-level script back to the OS, integer values are used directly as OS process status codes ("exit codes"). Other values are coerced in one way or another (but that particular behaviour is not the point of this ticket.)

Now, if one uses just a plain QUIT, currently 0 is returned as value to the calling script:

>> do {quit}
== 0 ;; Argument of this ticket: unattractive. Should be UNSET!.

This makes sense when considering the typical "0-is-OK" OS process status code convention. However, between Rebol scripts, it is arguably a bit unexpected.

Thus, I suggest that a plain QUIT between Rebol scripts returns UNSET! to the calling script. Similar to how what EXIT does for early exit from a function (versus RETURN to return a defined value), or BREAK for early exit from a loop (versus BREAK/return to break with a defined value).
Example code
;; Current behaviour:
>> do {quit}
== 0

;; Suggested behaviour:
>> unset? do {quit}
== true

Assigned ton/a Fixed in- Last Update15-Dec-2015 09:01


Date User Field Action Change
15-Dec-2015 09:01 abolka Description Modified -
15-Dec-2015 09:01 abolka Code Modified -
15-Dec-2015 09:01 abolka Ticket Added -