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.