220 37885 <2e63ae60069efc0fb81610ac2bd35491@kdab.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: "Mutz, Marc" <marc@kdab.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: API versioning: functions: overload; classes:
 typedef; variables: <meep>
Date: Fri, 20 Apr 2018 09:40:20 +0200
Lines: 74
Approved: news@gmane.org
Message-ID: <2e63ae60069efc0fb81610ac2bd35491@kdab.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"; format=flowed
X-Trace: blaine.gmane.org 1524209907 17407 195.159.176.226 (20 Apr 2018 07:38:27 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 20 Apr 2018 07:38:27 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCRPXDOU7ECRB4FS43LAKGQEN6H4ANQ@isocpp.org Fri Apr 20 09:38:23 2018
Return-path: <std-proposals+bncBCRPXDOU7ECRB4FS43LAKGQEN6H4ANQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wr0-f200.google.com ([209.85.128.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCRPXDOU7ECRB4FS43LAKGQEN6H4ANQ@isocpp.org>)
	id 1f9Qcg-0004SN-Mt
	for gclcip-std-proposals@m.gmane.org; Fri, 20 Apr 2018 09:38:22 +0200
Original-Received: by mail-wr0-f200.google.com with SMTP id a38-v6sf7807589wra.10
        for <gclcip-std-proposals@m.gmane.org>; Fri, 20 Apr 2018 00:40:33 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1524210033; cv=pass;
        d=google.com; s=arc-20160816;
        b=FvYiZeSdh2YdKWPBtMDSMkpMQTknQT1rbQawekVuXGiL461pCr1ZKpew9zugLNdCvM
         1rvpRbHQEq04gS4hEtA7XyFo12jOLaAB0exwul2L8hJBn25zV+1NO7ENuqLLT89Zyr6l
         +48ko5lbx8QdyZpv7XiVXqkesp8NsMa8UXJ1AWjHjgb+T6Gghr8HVE3KEALeNMpQj19f
         XrwOKFEuby+/Nyztui59O5clyR9Ztp4MpwAx3f1vwBdflA6F6VHLjb2+XBcAIMAow1jh
         QZ4MtCm/XJLWsKKk6s1jckLPAvTZ5sqZI2ydqq3C4cBq9MIfzCiutwX9Qfz4Ik7c6Uf1
         1Lyw==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:message-id:subject:to:from
         :date:mime-version:sender:arc-authentication-results
         :arc-message-signature:arc-authentication-results;
        bh=XrFrcGZJSxrzTgxiDgAQ2VsN3J8YflshnKfJkq2al0I=;
        b=ETgGCxy5Jo4fP6cpdN8Nmh2qxNYbFsL6Gjne9VaykiC10DGHv0Ro6qXWT2Tbs6o2Y6
         9zQZFL/z5uU05r58CHZFTr928UB4C+U7lbs42jy/OmSlvQrs4bf4m96t6GQ5KTpE9PSQ
         IawwUuaS8anve62AqEWbZPR4pUYRu1js1cm4sA5PHiKu0XZuiwkeAyJIJ687Vo3whd11
         h6/84BzoKrR14dyvSkpkrOCEFlhwDejU02LJEUTZH5ozwZFId+RNrnqVd5+39T6e8MA/
         NtjKW2/Onu0m1AHbmMP/l1xfpWEuNj7okWlSnBPqNn+Qypa6pmrXUfOS5adh6tj+4vjS
         SZkA==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@kdab.com header.s=dkim header.b=i4YKPHy2;
       spf=pass (google.com: domain of marc@kdab.com designates 176.9.126.58 as permitted sender) smtp.mailfrom=marc@kdab.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:sender:mime-version:date:from:to:subject
         :message-id:x-original-sender:x-original-authentication-results
         :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=XrFrcGZJSxrzTgxiDgAQ2VsN3J8YflshnKfJkq2al0I=;
        b=jgTPP2nZPQv9Jpc97YKJDstS4MOJsh1atom3GoRRRmFroX3p3HpuGoCYHY46GgWK0S
         YAANtIBmFTEQL5dzXCJpe4dg/D61MfpTXF8EX9767CzotYfY8NLRt2hzU8zkdMz+OuCR
         Sd0DCpbsN2DA2dSzfLexFeVa67shlrZzbVHD6TYiy9R/MIWH/7G0gcrrb4ny9sqA0yQA
         dxIc2v8Vuk+yEq77zYrWV/tgv+6q2yxHewCY4l+G3NHK+F40zj+FLgeBLx1ri/PxSoFW
         IY0TkcKgfJ4rkejDuSpOCtd5zQtyoErjQ+5eMikaBxk1HS402jdXLpvu5J6joQ2QMwNk
         3jog==
X-Gm-Message-State: ALQs6tDKP9bBoTwQnTQ9RBwJ4kx8J7kjIiQorRKqc8w1+5d9Gxe9//Uw
	T14iNPh6d9lQ/naNqGSic9C6cw==
X-Google-Smtp-Source: AIpwx4+LnSOZZWIBXRShiLtGsYruow0dYKVGDNiFGNM0l6Wwh6i1PPgBFskUkGicQqFNtQZj21HY5A==
X-Received: by 2002:adf:bd04:: with SMTP id j4-v6mr748267wrh.25.1524210033237;
        Fri, 20 Apr 2018 00:40:33 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.156.79 with SMTP id f76ls391718wme.9.gmail; Fri, 20 Apr
 2018 00:40:31 -0700 (PDT)
X-Received: by 10.28.235.3 with SMTP id j3mr1167539wmh.146.1524210031606;
        Fri, 20 Apr 2018 00:40:31 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1524210031; cv=none;
        d=google.com; s=arc-20160816;
        b=F6Ln1eIhelNO/SW9uhckTWQ/Eg7Rx8TdN3/fL3f7dp0BOxiAmucD1Gnx3YpDrafY8t
         ds5uhcMl3SABGOb1li454eO/jObPnahCPkEo409D7jHwUm9XaZNPxCHtLog4Yeiy6DRv
         6jkHhuVW2X2qFPGHMMNqtTIsMui4MNV6dMw9ktVB41QTzHzcjntOxUEuV+RAds8o/s9K
         OO/L+ZjVuVrtbC/foUyLEqTlTQtCVQrEnoLjcqZEPQOvJkwkQzOlG5J+NL5tWzW7qX3I
         wiUT8+6d0Rmp+9fzesqpnqqw1hZonUMgciVITiWDgWlUnUTcFO9ytJygdMoT2n4/4f+K
         3o1w==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=message-id:subject:to:from:date:content-transfer-encoding
         :mime-version:sender:dkim-signature:arc-authentication-results;
        bh=W3GK5gXRn04M2WwSHR0nMhkRK8E8YGBWkIk3iEeQ3m8=;
        b=0aj7pFt/q8MjIIkYPQAKfIeDPu5SmkPm2R7XS++OVrbjRtEY7JSyTVu2t2vInUlFI9
         qS4+Bn/kvlq1iHtwACVmyaCmEb4RNB7JDRCHjt80+UY93yD7Jqw8bbnQqsc21CM3cRzZ
         eAS1DY/DjTORiHcGf4Z1crYqqbubxb/fa5vk8nNI6af6P3YurynBTyE9XLVm+utpjv9s
         3BoAd3G+6IGg6YbbjP9nRzAWQ/CJatOAHaRRDkiZ+aQxf8OeLm+j6aPr2H+SLASjqxQM
         EWxE/3gOkjYI9yQzGj/4E9klOejsdJE264I/tamkhyzg2Rdxj1BF1XtG3az0wjU0zcRF
         bMfA==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@kdab.com header.s=dkim header.b=i4YKPHy2;
       spf=pass (google.com: domain of marc@kdab.com designates 176.9.126.58 as permitted sender) smtp.mailfrom=marc@kdab.com
Original-Received: from mail.kdab.com (mail.kdab.com. [176.9.126.58])
        by mx.google.com with ESMTPS id o84si624158wmb.46.2018.04.20.00.40.31
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 20 Apr 2018 00:40:31 -0700 (PDT)
Received-SPF: pass (google.com: domain of marc@kdab.com designates 176.9.126.58 as permitted sender) client-ip=176.9.126.58;
X-Virus-Scanned: amavisd-new at kdab.com
Original-Sender: marc@kdab.com
X-Sender: marc@kdab.com
X-Original-Sender: marc@kdab.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@kdab.com header.s=dkim header.b=i4YKPHy2;       spf=pass
 (google.com: domain of marc@kdab.com designates 176.9.126.58 as permitted
 sender) smtp.mailfrom=marc@kdab.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://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>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:37885
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/37885>

Hi,

This is an idea about API migration. Assume you have a public API, and 
you discover that you made a typo in an identifier (there are tons of 
other reasons to use the mechanisms that I'll show, but let's stay with 
typo for the sake of argument). How to fix?

For functions, we can add a new function and deprecated the old:

    // v1
    bar make_bra();

    // v2
    [[deprecated("use make_bar()")]] bar make_bra() { return make_bar(); 
}
    bar make_bar();

For classes, we can use a typedef:

    // v1
    class bra { ~~~ };

    // v2
    class bar { ~~~ };
    [[deprecated("use bar")]] using bra = bar;

For variables, there's no way:

     // v1
     static inline bar my_bra; // oops! no source migration path :(

I have two questions:

1. Is there anything in the pipeline that would address migrating 
variable names?
2. Assuming there's nothing, what about overloading the using keyword 
for this?

    // v2
    static inline bar my_bar;
    [[deprecated("use my_bar")]] using my_bra = my_bar; // variable 
'using'

Don't get hooked on the use of a global here, my main use-case would be 
replacing pairs with more targeted structs:

    template <typename T>
    struct minmax_result {
        T min, max;
        [[deprecated("use 'minmax_result'")]]
        operator std::pair<T, T>() const { return {min, max}; }
        [[deprecated("use 'min'")]]
        using first = min;
        [[deprecated("use 'max')]]
        using second = max;
    };

    template <typename T>
    minmax_result<const &T> minmax(const T& lhs, const T& rhs) { ~~~ }

    auto r = std::minmax(v, u);
    use(r.min);
    use(r.second); // WARNING: 'minmax_result<T>::second' is deprecated: 
use 'max'

Thanks,
Marc

-- 
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2e63ae60069efc0fb81610ac2bd35491%40kdab.com.

.
