|
From: Neil M. <ne...@Cs...> - 2008-11-23 01:12:31
|
On 22 Nov 2008, at 23:42, Twylite wrote:
> 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?
I don't think it's possible to avoid ambiguity while still preserving
ease of use. The alternative is to make less things optional, which
just becomes a pain. My preference is to make "on" a keyword in this
context. It's highly unlikely that a script or a variable would just
be named "on", and if we document this as a keyword in this context
then there should be no problem.
-- Neil
This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.
|