why doesn't formattedRead take args by ref instead of by pointer?

Timothee Cour thelastmammoth at gmail.com
Sat Aug 17 01:53:58 PDT 2013


adding an overload would increases likelihood for bugs but could be
possible. The same holds for getopt.

Another question:
the documentation for formattedRead is quite sparse, how does it explain
the following behavior:

  string s="a1 a2 a3";
  string a,b;
  uint n=formattedRead(s,"%s %s",&a,&b);
  assert(a=="a1" && b=="a2 a3");



On Mon, May 20, 2013 at 10:44 PM, Dmitry Olshansky <dmitry.olsh at gmail.com>wrote:

> 21-May-2013 01:39, Timothee Cour пишет:
>
>  That was indeed what I was using in my updated ref based
>> reimplementation of formattedRead (see my original post for the link),
>> and the other functions getopt, readf) are the same AFAIK.
>>
>> so why not add it to phobos:
>> it's safer (no null / invalid pointers)
>> simpler user code
>> more consistent with rest of phobos
>>
>> we could either make the existing by pointer functions enter a
>> deprecation path, or add a 'formattedReadRef' version for all those
>> functions.
>>
>> Thoughts?
>>
>
> You can just add an overload I bet. Since you can't read a pointer and &x
> is an r-value and (thank god) there wasn't decision to allow r-value as
> plain ref.
>
>
> --
> Dmitry Olshansky
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20130817/e92b68f4/attachment.html>


More information about the Digitalmars-d-learn mailing list