REBOL3 tracker
  0.9.12 beta
Ticket #0000534 User: anonymous

Project:



rss
TypeWish Statusdismissed Date16-Jan-2009 21:34
Versionalpha 31 Categoryn/a Submitted byBrianH
PlatformAll Severityminor Priorityhigh

Summary TRANSCODE /else on-error option
Description I would like a TRANSCODE option that would allow you to provide a fallback function that would be called on REBOL syntax errors.

The argument function would take two parameters:
- The string being transcoded at the position the value was supposed to start.
- The block that TRANSCODE would have returned here, with the defanged error and the next position. This might be better passed as two parameters - a decision is needed here.
TRANSCODE is a low-level function so it should raise an error if the parameter list is not compatible (by APPLY rules).

The function would return a block containing two values:
- A REBOL value (or #[unset!])
- The input string at the position that is supposed to be after that value.
This is the same as a regular TRANSCODE return. The return block will then be treated by TRANSCODE as if it was what TRANSCODE found there. If you want to pass through the original error, return the original TRANSCODE return block (or create one if we go for the 3-parameter proposal above). TRANSCODE probably should raise an error if the return value doesn't match the form it expects. We might consider allowing a return of #[none], and what that would mean.

This allows the user to specify fallback behavior that is possibly less strict than TRANSCODE would be. Or more - the fallback could raise the error, for instance. This would help with more advanced options for LOAD that have been proposed, and with more efficient use of TRANSCODE in combination with other proposals.
Example code
Three arg version:
transcode/else "," func [
    input [string!] error [error!] after [string!]
] [
    either parse/all input ["," after:] [
        reduce [copy/part input after after]
    ] [
        reduce [:error after]
    ]
]

Two arg version:
transcode/else "," func [
    input [string!] error [block!] /local after
] [
    either parse/all input ["," after:] [
        reduce [copy/part input after after]
    ] [:error]
]

Assigned ton/a Fixed in- Last Update26-Mar-2009 06:41


Comments
(0000336)
BrianH
20-Jan-2009 04:23

This would be needed to implement #671.
(0000507)
Carl
26-Mar-2009 06:41

See comments for #671.

Date User Field Action Change
26-Mar-2009 06:41 carl Status Modified reviewed => dismissed
26-Mar-2009 06:41 carl Comment : 0000507 Added -
26-Feb-2009 03:39 BrianH Comment : 0000336 Modified -
26-Feb-2009 03:36 BrianH Priority Modified normal => high
12-Feb-2009 22:19 BrianH Severity Modified not a bug => minor
20-Jan-2009 04:23 BrianH Severity Modified minor => not a bug
20-Jan-2009 04:23 BrianH Comment : 0000336 Added -
20-Jan-2009 04:21 BrianH Description Modified -
20-Jan-2009 04:21 BrianH Code Modified -
20-Jan-2009 04:21 BrianH Status Modified submitted => reviewed
16-Jan-2009 21:34 BrianH Ticket Added -