"with" should be deprecated with extreme prejudice
BCS
none at anon.com
Sun May 17 21:37:21 PDT 2009
Hello Andrei,
> BCS wrote:
>
>> Hello Andrei,
>>
>>> BCS wrote:
>>>
>>>> Hello Andrei,
>>>>
>>>>> dsimcha wrote:
>>>>>
>>>>>> Absolutely not. It's far too useful as syntactic sugar when
>>>>>> working heavily with plain old data structs, and saves a lot of
>>>>>> tedious repetition of the struct instance name.
>>>>>>
>>>>> Make it a member function! If you don't have access to the struct,
>>>>> use "s." as the prefix! I can't believe that's stopping you from
>>>>> getting work done!
>>>>>
>>>> I don't follow.
>>>>
>>> "s." is hardly any typing.
>>>
>> wrong bit, I should have cut more:
>>
>>> Make it a member function!
>>>
>> ?
>>
> In a member function there's no need to prefix each member.
>
> Andrei
>
how does that heplp you when you either don't have access to the type or
don't want to add the code using the type to it
module somelib;
struct S
{
int x, y, z;
}
module someapp;
import somelib;
void fn(char[] str, S s)
{
with(s)
{
sscanf(str.ptr, "<%i, %i, %i>", &x, &z, &y); // I'm not adding this
to S
}
}
More information about the Digitalmars-d
mailing list