develooper Front page | perl.perl5.porters | Postings from November 2011

New "dot" feature

Thread Next
Leon Brocard
November 2, 2011 13:57
New "dot" feature
Message ID:
Hello Porters,

I had a dream that Perl 5 had moved from using -> to using . like most 
modern languages. And moved the existing . for concatenation to ~ like 
Perl 6. Then I wrote the code and was shocked how tiny it was.

I have this in the leonbrocard/dot branch, but is is really one commit:

It's a very small tokenizer patch which interacts with a new "dot" 
feature. Then you can do things like:

  use feature qw(say dot);
  use CGI;
  my $q =;
  say ref($q);
  say $q.blockquote(
    "Many years ago on the island of",
    "there lived a Minotaur named",
    $q.strong("Fred.") ,

  my $arrayref = [1,2,3,4,5];
  say $arrayref.[-1];
  my $hashref = {a => 1, b => 2};
  say $hashref.{b};

  say "Hello" ~ "world";

I think this is quite a cute example of how features can do neat little 
tricks. There may be complicated interactions which break things in 
ways I haven't thought about, but it seems like a tiny patch that 
doesn't seem to slow parsing down. I'm not entirely sure that I'm 
proposing this seriously, but...

What do you think?

Cheers, Leon.

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