Skip to content

The final_act helper function name finally is misleading. #14

Description

The final_act helper function function, finally, is misleadingly named as it returns an object which, if not captured, will result in instant invocation of the given function object.

The following code looks correct but database lookups and insertions will fail as the 'final-act' was invoked at [1].

auto db_handle = my_db_api_open_db("My database name");
finally([db_handle]{ db_api_close_db(db_handle); }); // [1]
// do some lookups and insertions

I propose that finally is renamed to make_final_act or is replaced by a macro that captures the return value for the user into a uniquely named temporary variable (I prefer make_final_act).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions