Re: Proposal: shorthand object property setting syntax.
On 27.03.10 17:29, Stefan Marr wrote:
>
> 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...
Of course. I was primarily referring to Toorion's assertion that the
new syntax is less time-consuming. In doing so I assumed that typing N
lines of code consume less time than typing N+1. :)
> However, the proposal reminds me of Pascal's 'with'-construct:
>
> new(pointertob);
>
> with pointertob^ do
> begin
> a := 10;
> b := 'A';
> c := nil
> end;
Can one do something like "b := this.a"? This sounds like a huge can of
worms to me.
- Martin
Thread (15 messages)