develooper Front page | perl.perl5.porters | Postings from April 2010

Proposal for new keyword: with

Thread Next
Alberto Simões
April 16, 2010 11:16
Proposal for new keyword: with
Message ID:

This is not really an important suggestion. I think it makes sense when
thinking on the linguistic side of Perl (one of the more interesting
facets of Perl).

Pascal (yes, Pascal) has a 'with' keyword, mostly to be used with
records. Something like:

 with recordVariable do begin
   recordField1 := 'value';

It works as a shorthand to recordVariable.recordField1 and the like.

With the same idea in mind, Perl programmers usually write:

   for ($ScalarVariable) {

So, I though this might be more clear if written:

   with ($scalarVariable) {

As I said, I do not think this is nothing new. And probably it is not
relevant if its only application is the one presented above.

But who knows if somebody can find other interesting uses for it. Or
not... In the later case, just ignore the email :)

Alberto Simões

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