Skip to Content.
Sympa Menu

devel - Re: [sympa-developpers] Comments was Re: 2018 hackathon report

Subject: Developers of Sympa

List archive

Chronological Thread  
  • From: Marc Chantreux <address@concealed>
  • To: David Verdin <address@concealed>, address@concealed
  • Subject: Re: [sympa-developpers] Comments was Re: 2018 hackathon report
  • Date: Mon, 11 Jun 2018 10:18:37 +0200

hello David,

just to add another example (not pretending to defend anything, just
commenting, don't take attention, don't even read if you don't want,
no explicit lyrics, please don't think it's offensive in any way, don't
shoot a me please, thank you).

if we recomment to follow the PBP proposal on the if/else ( else should
be at the begin of the line), we get

my $result = some_process();
$status = do {
if ( $result > 5 ) { 'success' }
elsif ( $result > 0 and $result < 5 ) { 'not bad' }
else { 'fail' }
}

another use of it is a very temporary variable. things like

my $session = do {
my $very_temporary_variable = get_token $ctx;
do_things_with $very_temporary_variable;
get_session $very_temporary_variable;
};

that way, the $very_temporary_variable only exists on the context it's
useful. as someone said during the hackathon,
you can basically think the do keyword as a "almost a function but only
used here so not worth a namespace pollution".

regards,
marc




Archive powered by MHonArc 2.6.19+.

Top of Page