You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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]
]
CC – Data [ Version: alpha 31 Type: Wish Platform: All Category: n/a Reproduce: Always Fixed-in:none ]
The text was updated successfully, but these errors were encountered:
Submitted by: BrianH
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:
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:
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.
CC – Data [ Version: alpha 31 Type: Wish Platform: All Category: n/a Reproduce: Always Fixed-in:none ]
The text was updated successfully, but these errors were encountered: