220 18298 <CANh-dXn2p6Jy6rdd69iPHxnbZJUqWYvrV_yJ+qyE3BR96PPz2A@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: "'Jeffrey Yasskin' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Parsing Numbers
Date: Fri, 29 May 2015 09:31:54 -0700
Lines: 118
Approved: news@gmane.org
Message-ID: <CANh-dXn2p6Jy6rdd69iPHxnbZJUqWYvrV_yJ+qyE3BR96PPz2A@mail.gmail.com>
References: <eb5c19d6-074f-4ee4-8e2d-6d92349eb4be@isocpp.org>
 <555CDDEF.8000002@gmx.net> <CAA7U3HMbniu0_RE2ptbwXzUrP9qRxQ_NG7=fBxytyobJ-X+=Sw@mail.gmail.com>
 <555ECB8E.9010606@gmx.net> <CAA7U3HPQ-FNKV3sci2n7+7Pk2kwg7wtUabAv=6aRXFsnOmCK_w@mail.gmail.com>
 <55680FE0.9050608@gmx.net> <CAA7U3HP9G8Q+bTY7sNyLX4u1i8-XZ6YS9jLUYsVYf885UfTUMg@mail.gmail.com>
 <5568237D.7010802@gmx.net> <CAA7U3HNQszx-DOJZgdXPi0j2OMijzb6qYRu9NYKAzvCrVA48Rg@mail.gmail.com>
 <5568481E.3060709@gmx.net>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1432917144 14032 80.91.229.3 (29 May 2015 16:32:24 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 29 May 2015 16:32:24 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDDM34EO6QDRBEFJUKVQKGQEVWJJREI@isocpp.org Fri May 29 18:32:23 2015
Return-path: <std-proposals+bncBDDM34EO6QDRBEFJUKVQKGQEVWJJREI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ie0-f200.google.com ([209.85.223.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDDM34EO6QDRBEFJUKVQKGQEVWJJREI@isocpp.org>)
	id 1YyNCk-0003VR-ID
	for gclcip-std-proposals@m.gmane.org; Fri, 29 May 2015 18:32:18 +0200
Original-Received: by iepj10 with SMTP id j10sf124765385iep.0
        for <gclcip-std-proposals@m.gmane.org>; Fri, 29 May 2015 09:32:17 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:content-type:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=M/nEuwnCOx9U8JaeeS5/7qwdOikHvsj2ummKTJ4rFqM=;
        b=cKq7al4IH0HGUaslq8uL9K+rBfOqPpNtOKe8HEzjh+QYWlkd5lYIF/vjc0svV2EVXu
         c6j8sXHRxAyECLZeFLTLl8gloyDuyAaqASxYr7EwQhCDVAy568Ohvc1uA9jBWVqWqmGy
         vgBUDoc5UiVpkelZemCvolJOIbyUPlMGJO9vdFi10V1HatHKdsEHjhNsnxcW9WPDvJ7h
         hoALn6ARBfcGwa4LRuao1BiT1Gt3AA+waZaWISGl+whXhPQuPeBismE8kkpA/e6/gx4h
         IGRYWrhXnRyKIiUqKnLppbeIWS/ae66UdaLoR6HmrG6VceO6qqEhgRghPKdjkljIifVm
         VNew==
X-Gm-Message-State: ALoCoQl2sASuf/QPpeR58fVJVpeKBg/Qc1a/nZMeGeq+sE62HKNB/9R7BQWrdWOZPWnnlxy5em5B
X-Received: by 10.182.61.66 with SMTP id n2mr10844702obr.20.1432917137597;
        Fri, 29 May 2015 09:32:17 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.156.143 with SMTP id f137ls1003942ioe.60.gmail; Fri, 29
 May 2015 09:32:16 -0700 (PDT)
X-Received: by 10.107.156.71 with SMTP id f68mr11072366ioe.36.1432917136543;
        Fri, 29 May 2015 09:32:16 -0700 (PDT)
Original-Received: from mail-ie0-x235.google.com (mail-ie0-x235.google.com. [2607:f8b0:4001:c03::235])
        by mx.google.com with ESMTPS id kb9si1930882igb.48.2015.05.29.09.32.16
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 29 May 2015 09:32:16 -0700 (PDT)
Received-SPF: pass (google.com: domain of jyasskin@google.com designates 2607:f8b0:4001:c03::235 as permitted sender) client-ip=2607:f8b0:4001:c03::235;
Original-Received: by iepj10 with SMTP id j10so66664121iep.3
        for <std-proposals@isocpp.org>; Fri, 29 May 2015 09:32:16 -0700 (PDT)
X-Received: by 10.107.10.151 with SMTP id 23mr9145676iok.89.1432917136130;
 Fri, 29 May 2015 09:32:16 -0700 (PDT)
Original-Received: by 10.64.73.2 with HTTP; Fri, 29 May 2015 09:31:54 -0700 (PDT)
In-Reply-To: <5568481E.3060709@gmx.net>
X-Original-Sender: jyasskin@google.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of jyasskin@google.com designates 2607:f8b0:4001:c03::235 as permitted
 sender) smtp.mail=jyasskin@google.com;       dkim=pass header.i=@google.com;
       dmarc=pass (p=REJECT dis=NONE) header.from=google.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
X-Original-From: Jeffrey Yasskin <jyasskin@google.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:18298
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/18298>

FWIW, I think Jens' arguments are going to be convincing to the
committee, so it's probably a good idea to follow them in the first
iteration of this paper.

On Fri, May 29, 2015 at 4:06 AM, Jens Maurer <Jens.Maurer@gmx.net> wrote:
> On 05/29/2015 12:12 PM, Olaf van der Spek wrote:
>> 2015-05-29 10:29 GMT+02:00 Jens Maurer <Jens.Maurer@gmx.net>:
>>>> Can't the string_view one be easily generalized too?
>>>
>>> Which way?   Have a range_view that takes a pair of arbitrary
>>> iterators of type It?  Sure.  This feels even farther away
>>> from established STL precedence.
>>
>> No, I mean adding an overload taking two or three iterators..
>
> I'm looking for the most basic abstraction to be standardized.
>
> We've standardized quite a few non-basic abstractions, e.g.
> iostreams or num_get<>(), which leaves a performance gap between
> "what the standard provides" and "what the user could write himself
> when not needing the bells + whistles".  I don't want to have a
> gap discussion ever again in the area we're talking about.
>
> I have no sustained objection to standardizing various additional
> overloads in addition to standardizing the basic abstraction,
> if people feel like it.  (I'm not really in favor, because it
> blows up the std.lib interface, which makes it a little harder to
> learn each time we do that.)
>
>> I guess we'll include it anyway due to the aliasing concerns.
>>
>> File read() and write() also update the file pointer in a hidden way..
>> is doing so really that bad?
>
> File I/O has hidden state, yes.  Is that bad?  Maybe.  We also
> have pread and pwrite for those that don't like the hidden state.
>
>> If we get unified call syntax we even might be able to write is.parse()
>
> Yes, if string_view is the first parameter (which it currently isn't).
>
>>> Let's assume the "parse" function is inlined.  Ideally, string_view's
>>> components should be kept in registers and never hit memory.
>>> Now, the first "parse" call changes the value of the member of "s"
>>> holding s.begin() (let's call it s.first).  This write must hit
>>> memory, because s.first might point to itself or to s.end under
>>> the aliasing rules.
>>>
>>> In the second parse call, the "auto it = is.begin()"  and
>>> "is.end()" must read from memory afresh, because those values
>>> might have been changed by the write to s.first of the first
>>> parse call.
>>
>> is.begin will almost surely have been changed.
>
> Yes, sorry.
>
>>> End result: string_view's components are not kept in registers.
>>
>> True, but how big of a problem is one or two reads from L1 cache?
>
> That might not be the only effect.  Memory writes to an arbitrary
> location (from the viewpoint of the compiler) might inhibit
> code motion / scheduling between the two calls to parse, too,
> producing more pipeline stalls etc.
>
>>> When s.first and s.end are separate local variables, it's obvious
>>> to the compiler that an externally-supplied value cannot possibly
>>> point to them.
>>
>> Hmm, I'm inclined to call this a quality of implementation issue.
>
> As I said earlier, I failed to achieve the QoI for the "output"
> case and a similar interface structure.
>
>>>>> and can be made to look parallel with output.
>>>>> Output doesn't work
>>>>> with string_view at all, because its elements are const.
>>>>
>>>> True, but IMO we should punish input for that.
>>>
>>> When we're done, we should have a set of elementary parse()
>>> functions in the standard, and a corresponding set of output()
>>> functions.  Considering some in isolation is fine up to a point,
>>> but we shouldn't lose track of the big picture.
>>
>> Output / format functions are a whole different story. I'm not sure
>> it's worth it to worry about that for this proposal.
>
> My use case is a (say) JSON input / output library.
> I don't want this in the standard right now, but I do want to have
> the basic building blocks available so that I can write my own
> in C++ whose performance blows everything else out of the water while
> using standard library facilities for the basic building blocks.
>
> The status quo is that I won't even try, because I can't get rid of
> locale-dependent parsing / output formatting of numbers when using
> the standard library.
>
> Thanks,
> Jens
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.
