nobodyinperson,
@nobodyinperson@fosstodon.org avatar

Can we please have an alias 'but' for the 'and' binary operator in programming languages?

if outside and moving_slowly ⇒ if outside but moving_slowly
if online and not connected ⇒ if online but not connected

Such semantics made :perl: a bliss to write in some cases (if not ⇒ unless), although Perl doesn't have this 'but' alias. Probably can change itself at runtime to add this alias 😅

mjgardner,
@mjgardner@social.sdf.org avatar

@nobodyinperson Bliss to write but not to read as tortuous double-negatives pile up with maintenance. The ProhibitUnlessBlocks policy exists for a reason: https://metacpan.org/pod/Perl::Critic::Policy::ControlStructures::ProhibitUnlessBlocks

This applies to both unless and until. Congratulations if you've used them in the past: you contributed to 's reputation as a write-only language in the eyes of the person who had to revise your code to deal with more complicated conditions.

nobodyinperson,
@nobodyinperson@fosstodon.org avatar

@mjgardner Luckily I didn't write or publish anything serious in , let alone something that someone else would review. It was just one of my first programming languages to learn and I really liked these 'unless' and 'until' keywords because I think they make certain cases much more readable. But okay, if that's considered bad practice, oh well 🤷

mjgardner,
@mjgardner@social.sdf.org avatar

@nobodyinperson Oh yes, unless and until definitely make simple negative conditions read like English. I use them in tiny snippets sometimes: https://social.sdf.org/@mjgardner/111067530338170318

  • All
  • Subscribed
  • Moderated
  • Favorites
  • raku
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • anitta
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • provamag3
  • tester
  • Leos
  • megavids
  • JUstTest
  • All magazines