220 37372 <6725bbc8-a8db-40e1-a3f4-98ac05e23862@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: `offsetof` in a macro-less, modular world
Date: Fri, 16 Mar 2018 15:12:24 -0700 (PDT)
Lines: 158
Approved: news@gmane.org
Message-ID: <6725bbc8-a8db-40e1-a3f4-98ac05e23862@isocpp.org>
References: <c5f5ccc4-3267-442d-8cb2-de1ae103a38e@isocpp.org>
 <CALmDwq38-kBPK2QnEPLkzM9z7r_jXif7oBoO+A7CMm9XBUC96g@mail.gmail.com>
 <e7a864e9-a866-40d6-9688-95219dc34d92@isocpp.org> <71ed1718-d272-4920-92fe-3b59750e6fb8@isocpp.org>
 <CAHSYqdaG06U9DwCW57=UM5GrUHkXWV9Ah5u+1wDrisBSo_nQig@mail.gmail.com> <22ef47e6-e957-4519-820f-1decb09a116d@isocpp.org>
 <CAHSYqdZA9zarj3qL0otGwaQQU-g2Tkk7jEmWziFBWz=iYR2ANg@mail.gmail.com>
 <64578641-a89f-4b60-82ce-5183a54a3630@isocpp.org>
 <d9e85fb4-6296-44ee-81f8-7b8fdbc8822e@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2699_671267481.1521238344610"
X-Trace: blaine.gmane.org 1521238224 5018 195.159.176.226 (16 Mar 2018 22:10:24 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 16 Mar 2018 22:10:24 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBSMCWHKQKGQEPI5DRZQ@isocpp.org Fri Mar 16 23:10:20 2018
Return-path: <std-proposals+bncBCEKFTV6ZUMBBSMCWHKQKGQEPI5DRZQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f70.google.com ([209.85.213.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBSMCWHKQKGQEPI5DRZQ@isocpp.org>)
	id 1ewxYJ-0001Dr-RX
	for gclcip-std-proposals@m.gmane.org; Fri, 16 Mar 2018 23:10:20 +0100
Original-Received: by mail-vk0-f70.google.com with SMTP id h23sf7360734vke.20
        for <gclcip-std-proposals@m.gmane.org>; Fri, 16 Mar 2018 15:12:27 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=nNKfa5kypClTRVPoFNM8fYQpYH7A9K8/1244fvYKyK8=;
        b=ZeRrTxXlBb3N4ewMkbpDaiRa4iIH9BJSrR3NVApjI4qyDuXVj2+3uJVjiU/U/AAr03
         YoTVS8eFfcnptR38n9Wv39L36t9jZdyLJ+6i1ybUjOe3nsx35ZcSUUxrhasMSRdYl/WS
         zpxILDIC16tMTFWO7o1m6b+Tl3AJ7GMqlkvU7IwPK6zusfKZF5dJDjJ1ozQnJsVvaawl
         DJsNN+Mzq/LithYvc4zePjg6z1vGa/7pE/xzrdvx4cUkjeiKWBTBhvGLeVyqDd5zF1Co
         Ju37l/mgRJTSX0BpDGG98+YXSAY/cDu2eIlBbSWLJoHpE+Lo1E5PBjYQUcR+1Eco/jOR
         iEXg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=nNKfa5kypClTRVPoFNM8fYQpYH7A9K8/1244fvYKyK8=;
        b=OdqOSwu0Iooz2PFm/E1pHr2XBQEFI4dfGMdwfZzrOqqdJ+iB659BRUycLoUS9/WzMW
         xTsTm8+KHieTqhWCMcu3XjMUk8FOv7NQl19INupXBcnqSTvlPFr2ymVMtS4uR4aoWcCh
         +Yg89BphaoPcfg/fg/cqUGRorFnFMEZeuIx2YppywVy0P5en3lTLKVq59eQfSUKxhN/Z
         Jk9b8pjnb8XY9QZh6x69HKzULhS/re3AUw4sXc2KUgrSResGcKps60cN+XOmgcIg+OVk
         /9t9WZWgg+G7WcfM2kJ1gd3wCyQJsuAH53y6wJ6zmF4JqzVEiiZ6cq33oMY74zNMbmkU
         jSLA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=nNKfa5kypClTRVPoFNM8fYQpYH7A9K8/1244fvYKyK8=;
        b=uMH9f99dFCOZKPg/FyE9Fm44+S4/lhcw95aMmARwhMSaRIT9jdymwOfxc3tGy3O2EK
         GCLx21+2EBcyDMK7BkRZw+XNbiYUb7fQ+8x9VzGJPJjBpwYdVpPPR2Ek9C9Yyh/IQhG/
         4HoBRQLLTFnuZZLfTiJjMyN3M0ckaez6IOTa3Qvz3M6Woke3sDk42dc+bVKZ9aYRiVU4
         XgWLSyoqlLD6Z3nGx2x4xB+0s0Ea1xRSu/rbdH7IzbKY0900/fbSJ0DjrxNSM26DBbK1
         PSm9nWprR3vXD1E7ZZdyi8bQSlV3FlRlDwGnRyY6Uyl41wCgpWGL50ZbVIzCoJy0G4dx
         Pvcg==
X-Gm-Message-State: AElRT7Gc1SJd0EEtmt8Tza2j31TJgtmMM84SvudevZ/mB66kGAdEnU6I
	mhT8yuvtnOL3yquvv4DnsYmWmA==
X-Google-Smtp-Source: AG47ELsHE2bKEtHz21Z6TpruoodBczWAszx4vubvmTHxo54b2rPSRUAP94iK38GkfNFeR+F7y7VZ2w==
X-Received: by 10.176.18.91 with SMTP id s27mr1516333uac.70.1521238346643;
        Fri, 16 Mar 2018 15:12:26 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.31.67.2 with SMTP id q2ls775656vka.0.gmail; Fri, 16 Mar 2018
 15:12:25 -0700 (PDT)
X-Received: by 10.31.178.81 with SMTP id b78mr398144vkf.14.1521238345176;
        Fri, 16 Mar 2018 15:12:25 -0700 (PDT)
In-Reply-To: <d9e85fb4-6296-44ee-81f8-7b8fdbc8822e@isocpp.org>
X-Original-Sender: jmckesson@gmail.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:37372
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/37372>

------=_Part_2699_671267481.1521238344610
Content-Type: multipart/alternative; 
	boundary="----=_Part_2700_1124475017.1521238344610"

------=_Part_2700_1124475017.1521238344610
Content-Type: text/plain; charset="UTF-8"

On Friday, March 16, 2018 at 6:02:16 PM UTC-4, Marcin Jaczewski wrote:
>
>
>
> On Friday, March 16, 2018 at 6:23:12 PM UTC+1, Nicol Bolas wrote:
>>
>> On Friday, March 16, 2018 at 11:34:02 AM UTC-4, Hyman Rosen wrote:
>>>
>>> On Fri, Mar 16, 2018 at 11:16 AM, Nicol Bolas <jmck...@gmail.com> wrote:
>>>>
>>>> You just need to simultaneously modify C++ so that there is a built-in 
>>>>> equivalent
>>>>> to offsetof, and make offsetof a pre-defined macro that expands to 
>>>>> that.
>>>>>
>>>>
>>>> And if modules can't export macros, how will `import std.cstddef` give 
>>>> me access to that module?
>>>>
>>>
>>> What module?  I don't understand.
>>>
>>> Let me try again:
>>>
>>>    - Change C++ so that there is a built-in version of offsetof under a 
>>>    different name, say __offsetof.
>>>    - __offsetof is available for use in all C++ code without any header 
>>>    or module needed, just as sizeof is.
>>>    - Also change C++ so that offsetof is a pre-defined macro that 
>>>    expands to __offsetof.
>>>
>>>
>> Oh, when you said "built-in" you meant like "supplied by the compiler".
>>
>> So... what happens with people's code that *don't* include <cstddef> or 
>> <stddef> that happens to use the `offsetof` identifier? Admittedly this is 
>> a minor issue, as I rather doubt someone's going to make a class or 
>> function that conflicts with a fairly widely known C macro that gets 
>> included by quite a few things (even if only because of other useful 
>> things).
>>
>
> People who use  `<cstddef>` will still use `<cstddef>` we don not change 
> antything (this why I suggest leaving it alone).
> We add new keyword `real_super_offsetof` that will be available everywhere.
> Only problem would be migration of heder to modules usage but because 
> offsetof is macro we can safely use text replace to change it to new 
> keyword.
>

If it's going to be a direct, drop-in replacement, such that code which 
uses `offsetof` can be changed to use `new_offsetof` with no other 
changes... why make it a new identifier at all? Just have `offsetof` become 
a C++ keyword, and have the C++ versions of `<cstddef>` and `stddef.h` 
simply not define them.

I thought the whole point of using a new keyword was to give them a 
(presumably) better interface.

-- 
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/6725bbc8-a8db-40e1-a3f4-98ac05e23862%40isocpp.org.

------=_Part_2700_1124475017.1521238344610
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Friday, March 16, 2018 at 6:02:16 PM UTC-4, Marcin Jacz=
ewski wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><=
br><br>On Friday, March 16, 2018 at 6:23:12 PM UTC+1, Nicol Bolas wrote:<bl=
ockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-l=
eft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">On Friday, March 16, =
2018 at 11:34:02 AM UTC-4, Hyman Rosen wrote:<blockquote class=3D"gmail_quo=
te" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-=
left:1ex"><div dir=3D"ltr"><div><div class=3D"gmail_quote">On Fri, Mar 16, =
2018 at 11:16 AM, Nicol Bolas <span dir=3D"ltr">&lt;<a rel=3D"nofollow">jmc=
k...@gmail.com</a>&gt;</span> wrote:<blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr"><span><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-l=
eft:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><di=
v><div class=3D"gmail_quote"><div>You just need to simultaneously modify C+=
+ so that there is a built-in equivalent<br>to offsetof, and make offsetof =
a pre-defined macro that expands to that.</div></div></div></div></blockquo=
te></span><div><br>And if modules can&#39;t export macros, how will `import=
 std.cstddef` give me access to that module?</div></div></blockquote><div><=
br>What module?=C2=A0 I don&#39;t understand.<br><br></div></div></div></di=
v></blockquote><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-l=
eft:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><di=
v><div class=3D"gmail_quote"><div>Let me try again:<br><ul><li>Change C++ s=
o that there is a built-in version of <font face=3D"monospace, monospace">o=
ffsetof</font> under a different name, say <font face=3D"monospace, monospa=
ce">__offsetof</font>.</li><li><font face=3D"monospace, monospace">

<span style=3D"color:rgb(34,34,34);font-family:monospace,monospace;font-siz=
e:small;font-style:normal;font-weight:400;letter-spacing:normal;text-align:=
left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0p=
x;background-color:rgb(255,255,255);float:none;display:inline">__offsetof</=
span>=C2=A0</font>is available for use in all C++ code without any header o=
r module needed, just as <font face=3D"monospace, monospace">sizeof</font> =
is.</li><li>Also change C++ so that <font face=3D"monospace, monospace">off=
setof</font>=C2=A0is a pre-defined macro that expands to <font face=3D"mono=
space, monospace">

<span style=3D"color:rgb(34,34,34);font-family:monospace,monospace;font-siz=
e:small;font-style:normal;font-weight:400;letter-spacing:normal;text-align:=
left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0p=
x;background-color:rgb(255,255,255);float:none;display:inline">__offsetof</=
span></font>.</li></ul></div></div></div></div></blockquote><div><br>Oh, wh=
en you said &quot;built-in&quot; you meant like &quot;supplied by the compi=
ler&quot;.<br><br>So... what happens with people&#39;s code that <i>don&#39=
;t</i> include &lt;cstddef&gt; or &lt;stddef&gt; that happens to use the `o=
ffsetof` identifier? Admittedly this is a minor issue, as I rather doubt so=
meone&#39;s going to make a class or function that conflicts with a fairly =
widely known C macro that gets included by quite a few things (even if only=
 because of other useful things).<br></div></div></blockquote><div><br>Peop=
le who use=C2=A0 `&lt;cstddef&gt;` will still use `&lt;cstddef&gt;` we don =
not change antything (this why I suggest leaving it alone).<br>We add new k=
eyword `real_super_offsetof` that will be available everywhere.<br>Only pro=
blem would be migration of heder to modules usage but because offsetof is m=
acro we can safely use text replace to change it to new keyword.<br></div><=
/div></blockquote><div><br>If it&#39;s going to be a direct, drop-in replac=
ement, such that code which uses `offsetof` can be changed to use `new_offs=
etof` with no other changes... why make it a new identifier at all? Just ha=
ve `offsetof` become a C++ keyword, and have the C++ versions of `&lt;cstdd=
ef&gt;` and `stddef.h` simply not define them.<br><br>I thought the whole p=
oint of using a new keyword was to give them a (presumably) better interfac=
e.<br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/6725bbc8-a8db-40e1-a3f4-98ac05e23862%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/6725bbc8-a8db-40e1-a3f4-98ac05e23862=
%40isocpp.org</a>.<br />

------=_Part_2700_1124475017.1521238344610--

------=_Part_2699_671267481.1521238344610--

.
