"with" should be deprecated with extreme prejudice

BCS none at anon.com
Sun May 17 21:55:15 PDT 2009


Hello Nick,

> "BCS" <none at anon.com> wrote in message
> news:a6268ff5f598cba54ecba238c8 at news.digitalmars.com...
> 
>> void fn(char[] str, S s)
>> {
>> with(s)
>> {
>> sscanf(str.ptr, "<%i, %i, %i>", &x, &z, &y); // I'm not adding
>> this to S
>> }
>> }
> You don't really see that as an improvement over this do you?:
> 
> void fn(char[] str, S s)
> {
> sscanf(str.ptr, "<%i, %i, %i>", &s.x, &s.z, &s.y);
> }
> If anything, the "with" version looks worse to me, and those three
> "s." are trivial.
> 

I do like it over the full form:

void someFn()
{
  static void fn(char[] str, S s)
  {
     sscanf(str.ptr, "<%i, %i, %i>", &s.x, &s.z, &s.y);
  }
  fn(str);
}





More information about the Digitalmars-d mailing list