|
From: Twylite <tw...@cr...> - 2008-11-22 23:42:54
|
Hi,
> try ?-matchcommand cmd? script ?handlers ...? ?finally script?
>
> Where -matchcommand is the command to use to do errorCode matching
> and defaults to {switch -glob --}. (May need a -- marker to eliminate
> ambiguity). The syntax of the handlers part would be:
>
> on exception-types ?vars? ?errorPattern? body ?errorPattern
> body ...?
I'm very uncomfortable with this syntax. It is potentially ambiguous
and feels very DWIMy (in a bad way).
try {
# do stuff
} on error {
puts hello
} finally {
puts goodbye
}
... is ambiguous. It could be interpreted the way you think, or with
"puts hello" as the vars and "finally" as the error pattern.
Consider also:
try { ... } on error {em opts} "POSIX *" { body } on break
Is "on break" an errorPattern and body, or the start of a new exception
handler?
One can construct other ambiguities that exploit the inability to
distinguish between a pattern for a pluggable matcher (i.e. you can't
make assumtions about what is and isn't a valid input) and the keywords
of the [try] itself.
Regards,
Twylite
|