Project

General

Profile

Actions

Feature #10042

closed

Deprecate postfix rescue syntax for removal in 3.0

Added by headius (Charles Nutter) over 10 years ago. Updated almost 4 years ago.

Status:
Feedback
Target version:
-
[ruby-core:63754]

Description

The postfix rescue notation is convenient...but almost always is a really bad antipattern.

An example of the notation:

Integer(f) rescue f # returns f if it is not parseable as an Integer

It silently ignores all StandardError raised by a piece of code...which often covers many more exceptions than the user wants to be ignoring.

It also hides the cost of constructing and throwing away all those ignored exceptions.

I believe Matz has even said in the past that he regrets adding the feature.

In any case, I propose that "rescue nil" should be deprecated with a warning (either always on or only when verbose) and we should plan to remove it in 3.0.

Who's with me?!


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #6739: One-line rescue statement should support specifying an exception classFeedbackmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0