develooper Front page | perl.perl5.porters | Postings from August 2013

Re: [perl #116020] toggle operator missing reset: proposal

Thread Previous | Thread Next
August 29, 2013 15:48
Re: [perl #116020] toggle operator missing reset: proposal
Message ID:
tlhackque wrote:
>>One might imagine a toggle object as a middle ground -- e.g.
>>    $toggle = Toggle::new( '...', sub {/^--a$/} , sub {/^--b$/}); #

Can be done much more neatly by a call-checker plugin and custom ops.
I'm thinking of it looking something like

	$out .= $_ if toggle /^--a$/, /^--b$/;

Named toggles just need a slight extension to put their state somewhere
visible.  As the hiddenness of a toggle's state is a nasty aspect of
the core feature, I'd be inclined to make these toggles use an explicit
variable, whose lifetime can be controlled in the usual ways:

	my $tog;
	reset_toggle $tog;
	$out .= $_ if toggle $tog, /^--a$/, /^--b$/;

>>such as
>>      reset ['label']; or reset( ['label'], 2 );

If a toggle reset feature is added to the core, it should not further
overload an existing core operator, especially one that is presently


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About