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

Proposal for new keyword: with

Thread Next
From:
Alberto Simões
Date:
April 16, 2010 11:16
Subject:
Proposal for new keyword: with
Message ID:
4BC8A94D.2030005@alfarrabio.di.uminho.pt
Hello

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';
   doSomthing(otherRecordField)
 end;

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

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

   for ($ScalarVariable) {
       s/.../.../;
       ...
   }

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 :)

Cheers
-- 
Alberto Simões

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