Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Scope-Guard CPAN distribution.

Report information
The Basics
Id: 55938
Status: resolved
Priority: 0/
Queue: Scope-Guard

People
Owner: CHOCOLATE [...] cpan.org
Requestors: TIMB [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: An alternative simpler procedural interface, like Scope::OnExit, would be nice
Firstly, thanks for Scope::Guard! Very handy. Compare Scope::Guard: my $sg = Scope::Guard->new(sub { ... }); with Scope::OnExit: on_scope_exit { ... }; I'd like Scope::Guard to provide a function with a similar interface that can be optionally imported. Something like: my $sg = scope_guard_exit { ... }; That would be trivial to implement and greatly reduce the visual overhead of the current interface. It would be worth adding a croak "Can't create a Scope::Guard in void context" unless defined wantarray; to new() so both new and scope_guard_exit() would have that sanity check.
Hi, Tim. Thanks for your feedback. I've added this to 0.10. I've been meaning to add this for a while, but never got round to it. I've kept the void context usage, but added a note about it to the documentation. Thanks again, chocolateboy.
I've applied your void-context usage patch both to myself and Scope::Guard 0.20. Many thanks! chocolateboy