Menu

#60 multiple-pattern catch expansion is incorrect

Need_by_1.0
open
5
2006-12-08
2005-05-30
No

From
http://www.eros-os.org/pipermail/e-lang/2004-April/009810.html
:

? try { throw("oops") } catch ==1 {}
# problem: oops

? try { throw("oops") } catch ==1 {} catch ==2 {}
# problem: no match: problem: oops

The expansion for multiple-catch-clause try-catch does
not follow the
semantics of the kernel try-catch when the pattern
match fails - it
creates a new exception instead of simply passing
on/rethrowing the
unmatched one.

This will be important once E has a useful exception
type system (which
I am working on a proposal for).

(A similar problem exists with matchers in object
definitions, with the
additional complication that even in Kernel-E,
matcher-with-failing-pattern is not the same as
no-matcher. This is why
help(require) doesn't work.)

? e`try {} catch a {} catch b {}`
# value: e`try {
# null
# } catch specimen_1 {
# if (specimen_1 =~ a) {
# null
# } else {
# if (specimen_1 =~ b) {
# null
# } else {
# throw.run("no match: ".add(specimen_1))
# }
# }
# }`

Possible solutions:

1. Replace e`throw("no match: " + @x)` with
e`throw($x)`, though there
will still be an extra throw() in the stack trace.

2. Allow an arbitrary number of catch clauses in Kernel-E.

3. Somehow make match failure of all of the individual
patterns in the
expansion cause failure of the try-catch expression's
pattern.

4. Expand each catch clause into a nested try-catch.

Discussion

  • Mark Samuel Miller

    • assigned_to: nobody --> caplet
     
  • Mark Samuel Miller

    • milestone: 495443 --> Need_by_1.0
     

Log in to post a comment.

MongoDB Logo MongoDB