develooper Front page | perl.perl5.porters | Postings from December 2020

Making formats an opt-opt feature; gaining much syntax

Thread Next
From:
Paul "LeoNerd" Evans
Date:
December 10, 2020 11:53
Subject:
Making formats an opt-opt feature; gaining much syntax
Message ID:
20201210115301.029f294e@shy.leonerd.org.uk
What is the current overall state/feeling about formats in core perl?

I ask because there are so many (IMHO stupid annoying) punctuation vars
related purely to formats. I could imagine a named feature, default on,
that some newer version of perl might eventually turn off.

E.g. what if we could

  use v5.34;

and get a whole bunch of syntax back?


Right now, e.g. I note that `$=` is the "current page length of the
currently selected output channel, default 60 lines". How useless in
the modern age. Someone suggested a spelling for the "numerical in"
operator, e.g which would be spelled like

   4 @= 1..10  # true
  12 @= 1..10  # false

Now, I'm not mailing to debate the merits of that particular syntax,
but I note that right now we can't have @= as an operator because $=
exists as a superglobal and thus @= is just the normal array part of it.
All because of formats.

Likewise, `$:` is the "current set of characters after which a string
may be broken to fill continuation lines in a format". Again I vote
pointless. I had wanted slot variables of some core-supported
object/class syntax to be spelled like

   class Person {
       has $:name;
       method greet { say "My name is $:name"; }
   }

But `$:` gets in its way. I am reasonably confident that nobody has
ever wanted to set the continuation line characters for the currently
selected format while writing a modern class module. 

I feel that a "modern" Perl could do without these legacy
format-related variables, if it gains us the ability to even consider
lots of new useful syntax ideas that we'd much rather have instead. The
above are just two examples I thought up in 5 minutes, I'm sure over
the past decades we'll have had many more.

I propose that we could just gate the entire concept of formats behind
a named feature like 'format'. Like the 'indirect' feature it would
default on of course, but it is there for people to opt out of.

  no feature 'format';

More specifically, the list of variables that would affect are:

  $^A  $^L  $%  $-  $:  $=  $^  $~


(cross-posted to github as https://github.com/Perl/perl5/issues/18393)

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About