Wiki

Ticket #86 (closed enhancement: fixed)

Opened 10 years ago

Last modified 6 years ago

Add "try/catch" expression encapsulating any expression

Reported by: Chuck Owned by: Chuck
Priority: minor Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

x = int.parse(input) catch FormatError get 0

See full discussion at  Shortcut syntax idea for catch.

Attachments

tryCatchExpr.patch Download (8.4 KB) - added by hopscc 7 years ago.
tryCatchExpr1.patch Download (10.2 KB) - added by hopscc 6 years ago.

Change History

Changed 10 years ago by Chuck

Per the discussion, the syntax should start with the try keyword:

x = try int.parse(input) catch FormatError get 0

Also, there are implementation hints in the discussion.

Changed 10 years ago by Chuck

  • type changed from defect to enhancement

Changing from defect to enhancement.

Changed 7 years ago by hopscc

  • summary changed from Add "catch" for any expression to Add "try/catch" expression encapsulating any expression

Changed 7 years ago by hopscc

  • owner set to hopscc
  • status changed from new to assigned

Changed 7 years ago by hopscc

Changed 7 years ago by hopscc

  • owner changed from hopscc to Chuck

Implements simplified case - trycatch expression as target of assignment statement.

Use in any other expression or statement generate compiler error

tryExpr0.cobra(6): error: Can only use a tryCatch expression as the simple target of an assignment (e.g "ID = try EXPR catch EXCEPTION get EXPR". More complicated expressions cannot have code generated without side effects.

Changed 6 years ago by hopscc

Changed 6 years ago by hopscc

Second patch implements full support in any expression( on .Net).
Java version still constrained to simple assignment expressions
pending closures in Java

Tests extended somewhat from first patch.

Changed 6 years ago by Charles

bump

Changed 6 years ago by Charles

looking now

Changed 6 years ago by Charles

  • status changed from assigned to closed
  • resolution set to fixed

Nicely done.

Patched applied in changeset:2690

Note: See TracTickets for help on using tickets.