Re: Proposal: shorthand object property setting syntax.
On 27 Mar 2010, at 17:23, Martin Jansen wrote:
> On 27.03.10 17:02, Toorion wrote:
>> $myLongNameObject = new MyLongNameObject();
>> $myLongNameObject->property1 = '11111';
>> $myLongNameObject->property2 = '22222';
>> $myLongNameObject->property3 = '33333';
>> $myLongNameObject->property4 = '44444';
>> $myLongNameObject->property5 = '55555';
>
> [...]
>
>> $MyLongNameObject = new MyLongNameObject() {
>> $property1 = '1111';
>> $property2 = '2222';
>> $property3 = '4444';
>> $property4 = '5555';
>> }
>
> What exactly do you gain with the new syntax? You don't save LOC with
> it (actually it requires one more line) and you still have to type all
> the property names. Using an editor with code completion one can
> produce the code in the current syntax pretty quickly after all.
LOC isn't a very useful metric anyway...
However, the proposal reminds me of Pascal's 'with'-construct:
http://en.wikipedia.org/wiki/Pascal_(programming_language)
new(pointertob);
with pointertob^ do
begin
a := 10;
b := 'A';
c := nil
end;
>
> - Martin
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
Stefan Marr
Software Languages Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://soft.vub.ac.be/~smarr
Phone: +32 2 629 2974
Fax: +32 2 629 3525
Thread (15 messages)