MESSAGE
DATE | 2016-11-05 |
FROM | ruben safir
|
SUBJECT | Subject: [Learn] Fwd: Re: const T vs T const
|
From learn-bounces-at-nylxs.com Sat Nov 5 02:24:52 2016 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id 5249E161312; Sat, 5 Nov 2016 02:24:52 -0400 (EDT) X-Original-To: learn-at-nylxs.com Delivered-To: learn-at-nylxs.com Received: from [10.0.0.62] (flatbush.mrbrklyn.com [10.0.0.62]) by mrbrklyn.com (Postfix) with ESMTP id E6236160E77 for ; Sat, 5 Nov 2016 02:24:49 -0400 (EDT) References: <57e973f7$0$3995$e4fe514c-at-newszilla.xs4all.nl> <87y42dubze.fsf-at-gmail.com> To: learn-at-nylxs.com From: ruben safir X-Forwarded-Message-Id: <57e973f7$0$3995$e4fe514c-at-newszilla.xs4all.nl> <87y42dubze.fsf-at-gmail.com> Message-ID: <9721941c-4729-59e8-62ed-5256dc51e769-at-mrbrklyn.com> Date: Sat, 5 Nov 2016 02:24:49 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <87y42dubze.fsf-at-gmail.com> Content-Type: multipart/mixed; boundary="------------5B238A237CD3043287B9DB96" Subject: [Learn] Fwd: Re: const T vs T const X-BeenThere: learn-at-nylxs.com X-Mailman-Version: 2.1.17 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: learn-bounces-at-nylxs.com Sender: "Learn"
This is a multi-part message in MIME format. --------------5B238A237CD3043287B9DB96 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit
It was possibly in this newsgroup where the topic "const T vs T const" was discussed some months ago. (Or it might have been "comp.lang.c".)
Dan Sacks famously wrote about it and recommended "T const" IIRC.
I now found something new about this topic in the "Library Design Guidlines" for C++: quote
const goes in the wrong place, i.e., to the left
unquote. Thus, they acknowledge what Dan Sacks wrote by using "wrong", only to then recommend the opposite, i.e., "left".
Why? Maybe because tradition dictates this. (No rationale is given there.)
--------------5B238A237CD3043287B9DB96 Content-Type: message/rfc822; name="Re: const T vs T const.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: const T vs T const.eml"
Path: reader2.panix.com!panix!goblin1!goblin.stu.neva.ru!border1.nntp.ams1.giganews.com!nntp.giganews.com!buffer1.nntp.ams1.giganews.com!buffer2.nntp.ams1.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 26 Sep 2016 13:56:17 -0500 Date: Mon, 26 Sep 2016 21:56:18 +0300 From: Paavo Helde User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.8) Gecko/20151117 FossaMail/25.1.9 MIME-Version: 1.0 Newsgroups: comp.lang.c++ Subject: Re: const T vs T const References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-7cNirV39X/3YWxba+Q8YZ/zmJWvF7EBE0wA4mpnfj2ovj+8BhqyhQvlkjuSl1aZJFXHrqraSx0PqMIk!i8gCUth8cSaqoez2JkyCZje8VZmdGmHY2FlXk5xi07qf5gP/LGAbTkNCEB651+QmILoZ95EzBcA= X-Complaints-To: abuse-at-giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2084 Xref: panix comp.lang.c++:1123873
On 26.09.2016 20:50, Stefan Ram wrote: > It was possibly in this newsgroup where the topic > "const T vs T const" was discussed some months ago. > (Or it might have been "comp.lang.c".) > > Dan Sacks famously wrote about it and recommended > "T const" IIRC. > > I now found something new about this topic in the > "Library Design Guidlines" for C++: quote > > const goes in the wrong place, i.e., to the left > > unquote. Thus, they acknowledge what Dan Sacks > wrote by using "wrong", only to then recommend > the opposite, i.e., "left". > > Why? Maybe because tradition dictates this. (No > rationale is given there.)
Yes, "T const" would be more regular. However, lots of people prefer "const T". I guess this is just because when you talk about weather in English then "constant rain" often makes more sense than "rain constant".
Cheers Paavo
--------------5B238A237CD3043287B9DB96 Content-Type: message/rfc822; name="Re: const T vs T const.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: const T vs T const.eml"
Path: reader2.panix.com!panix!bloom-beacon.mit.edu!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!xmission!nnrp.xmission!.POSTED!not-for-mail From: legalize+jeeves-at-mail.xmission.com (Richard) Newsgroups: comp.lang.c++ Subject: Re: const T vs T const Date: Mon, 26 Sep 2016 19:04:08 +0000 (UTC) Organization: multi-cellular, biological Sender: legalize+jeeves-at-mail.xmission.com Message-ID: References: Reply-To: (Richard) legalize+jeeves-at-mail.xmission.com NNTP-Posting-Host: shell.xmission.com X-Trace: news.xmission.com 1474916648 22664 2607:fa18:0:beef::4 (26 Sep 2016 19:04:08 GMT) X-Complaints-To: abuse-at-xmission.com NNTP-Posting-Date: Mon, 26 Sep 2016 19:04:08 +0000 (UTC) X-Reply-Etiquette: No copy by email, please Mail-Copies-To: never X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: legalize-at-shell.xmission.com (Richard) Xref: panix comp.lang.c++:1123874
[Please do not mail me a copy of your followup]
Paavo Helde spake the secret code thusly:
>Yes, "T const" would be more regular. However, lots of people prefer >"const T".
In interviews I ask people to write the declaration for a constant pointer to constant character. When they've only ever seen const on the left, they freeze up. -- "The Direct3D Graphics Pipeline" free book The Computer Graphics Museum The Terminals Wiki Legalize Adulthood! (my blog)
--------------5B238A237CD3043287B9DB96 Content-Type: message/rfc822; name="Re: const T vs T const.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: const T vs T const.eml"
Path: reader2.panix.com!panix!goblin1!goblin.stu.neva.ru!border1.nntp.ams1.giganews.com!nntp.giganews.com!buffer1.nntp.ams1.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 26 Sep 2016 14:10:48 -0500 Date: Mon, 26 Sep 2016 22:10:49 +0300 From: Paavo Helde User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.8) Gecko/20151117 FossaMail/25.1.9 MIME-Version: 1.0 Newsgroups: comp.lang.c++ Subject: Re: const T vs T const References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-C3Fa3OxEHtdTEzhWqkvaatJ5QUTiVtWgH0RUZYR0+2ZZ2EPj2mN/oe5VrcxzDBpHc1Pw6kix6gCeCpJ!EgNIZ++pYa1BeqZMwjD4uGhuSJr35PpqGTVQ1QbbAO0uZDpQJq3DanC01eIhDuosq8kHuDg/z48= X-Complaints-To: abuse-at-giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 1810 Xref: panix comp.lang.c++:1123875
On 26.09.2016 22:04, Richard wrote: > [Please do not mail me a copy of your followup] > > Paavo Helde spake the secret code > thusly: > >> Yes, "T const" would be more regular. However, lots of people prefer >> "const T". > > In interviews I ask people to write the declaration for a constant > pointer to constant character. When they've only ever seen const on > the left, they freeze up.
And if they have only ever seen 'char const *p', do they not freeze up? Just curious...
--------------5B238A237CD3043287B9DB96 Content-Type: message/rfc822; name="Re: const T vs T const.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: const T vs T const.eml"
Path: reader2.panix.com!panix!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Chris M. Thomasson" Newsgroups: comp.lang.c++ Subject: Re: const T vs T const Date: Mon, 26 Sep 2016 12:21:46 -0700 Organization: n/a Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 26 Sep 2016 19:21:35 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="739b93b3e8fb02997bb34eb27d938fcc"; logging-data="6809"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX19EGno8SOOGJo3e+UXhbKl3s1OMMePWC5Y=" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 In-Reply-To: Cancel-Lock: sha1:6JL+x5uJPfWwdK1DO8VPR4M6Cg0= Xref: panix comp.lang.c++:1123877
On 9/26/2016 12:10 PM, Paavo Helde wrote: > On 26.09.2016 22:04, Richard wrote: >> [Please do not mail me a copy of your followup] >> >> Paavo Helde spake the secret code >> thusly: >> >>> Yes, "T const" would be more regular. However, lots of people prefer >>> "const T". >> >> In interviews I ask people to write the declaration for a constant >> pointer to constant character. When they've only ever seen const on >> the left, they freeze up. > > And if they have only ever seen 'char const *p', do they not freeze up? > Just curious...
IMVHO, they really shouldn't. I personally write these things from right to left, so a constant pointer to a constant character would be:
char const* const
Read right to left, it is const *, to const char.
IMHO, its pretty straightforward.
--------------5B238A237CD3043287B9DB96 Content-Type: message/rfc822; name="Re: const T vs T const.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: const T vs T const.eml"
Path: reader2.panix.com!panix!bloom-beacon.mit.edu!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!xmission!nnrp.xmission!.POSTED!not-for-mail From: legalize+jeeves-at-mail.xmission.com (Richard) Newsgroups: comp.lang.c++ Subject: Re: const T vs T const Date: Mon, 26 Sep 2016 23:15:49 +0000 (UTC) Organization: multi-cellular, biological Sender: legalize+jeeves-at-mail.xmission.com Message-ID: References: Reply-To: (Richard) legalize+jeeves-at-mail.xmission.com NNTP-Posting-Host: shell.xmission.com X-Trace: news.xmission.com 1474931749 31424 2607:fa18:0:beef::4 (26 Sep 2016 23:15:49 GMT) X-Complaints-To: abuse-at-xmission.com NNTP-Posting-Date: Mon, 26 Sep 2016 23:15:49 +0000 (UTC) X-Reply-Etiquette: No copy by email, please Mail-Copies-To: never X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: legalize-at-shell.xmission.com (Richard) Xref: panix comp.lang.c++:1123881
[Please do not mail me a copy of your followup]
Paavo Helde spake the secret code thusly:
>On 26.09.2016 22:04, Richard wrote: >> [Please do not mail me a copy of your followup] >> >> Paavo Helde spake the secret code >> thusly: >> >>> Yes, "T const" would be more regular. However, lots of people prefer >>> "const T". >> >> In interviews I ask people to write the declaration for a constant >> pointer to constant character. When they've only ever seen const on >> the left, they freeze up. > >And if they have only ever seen 'char const *p', do they not freeze up? >Just curious...
I don't know. Noone I've interviewed has ever been able to answer the question without help. -- "The Direct3D Graphics Pipeline" free book The Computer Graphics Museum The Terminals Wiki Legalize Adulthood! (my blog)
--------------5B238A237CD3043287B9DB96 Content-Type: message/rfc822; name="Re: const T vs T const.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: const T vs T const.eml"
Path: reader2.panix.com!panix!news.linkpendium.com!news.linkpendium.com!news.snarked.org!xmission!nnrp.xmission!.POSTED!not-for-mail From: legalize+jeeves-at-mail.xmission.com (Richard) Newsgroups: comp.lang.c++ Subject: Re: const T vs T const Date: Mon, 26 Sep 2016 23:16:32 +0000 (UTC) Organization: multi-cellular, biological Sender: legalize+jeeves-at-mail.xmission.com Message-ID: References: Reply-To: (Richard) legalize+jeeves-at-mail.xmission.com NNTP-Posting-Host: shell.xmission.com X-Trace: news.xmission.com 1474931792 31464 2607:fa18:0:beef::4 (26 Sep 2016 23:16:32 GMT) X-Complaints-To: abuse-at-xmission.com NNTP-Posting-Date: Mon, 26 Sep 2016 23:16:32 +0000 (UTC) X-Reply-Etiquette: No copy by email, please Mail-Copies-To: never X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: legalize-at-shell.xmission.com (Richard) Xref: panix comp.lang.c++:1123882
[Please do not mail me a copy of your followup]
(Richard) legalize+jeeves-at-mail.xmission.com spake the secret code thusly:
>[Please do not mail me a copy of your followup] > >Paavo Helde spake the secret code > thusly: > >>On 26.09.2016 22:04, Richard wrote: >>> [Please do not mail me a copy of your followup] >>> >>> Paavo Helde spake the secret code >>> thusly: >>> >>>> Yes, "T const" would be more regular. However, lots of people prefer >>>> "const T". >>> >>> In interviews I ask people to write the declaration for a constant >>> pointer to constant character. When they've only ever seen const on >>> the left, they freeze up. >> >>And if they have only ever seen 'char const *p', do they not freeze up? >>Just curious... > >I don't know. Noone I've interviewed has ever been able to answer >the question without help.
...and all their attempts had const on the left until they tried to figure out how to express the idea that the pointer was const and then they failed. -- "The Direct3D Graphics Pipeline" free book The Computer Graphics Museum The Terminals Wiki Legalize Adulthood! (my blog)
--------------5B238A237CD3043287B9DB96 Content-Type: message/rfc822; name="Re: const T vs T const.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: const T vs T const.eml"
Path: reader2.panix.com!panix!goblin2!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost2.xs4all.net!not-for-mail Subject: Re: const T vs T const Newsgroups: comp.lang.c++ References: From: Wouter van Ooijen Date: Mon, 26 Sep 2016 21:16:12 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <57e973f7$0$3995$e4fe514c-at-newszilla.xs4all.nl> NNTP-Posting-Host: 2001:980:a9b1:1:8c7:2877:c06d:a6ef X-Trace: 1474917367 dreader35.news.xs4all.nl 3995 [2001:980:a9b1:1:8c7:2877:c06d:a6ef]:55485 X-Complaints-To: abuse-at-xs4all.nl Xref: panix comp.lang.c++:1123876
Op 26-Sep-16 om 9:04 PM schreef Richard: > [Please do not mail me a copy of your followup] > > Paavo Helde spake the secret code > thusly: > >> Yes, "T const" would be more regular. However, lots of people prefer >> "const T". > > In interviews I ask people to write the declaration for a constant > pointer to constant character. When they've only ever seen const on > the left, they freeze up.
I would refuse to write that as one declaration.
Wouter "Objects? No Thanks!" van Ooijen
--------------5B238A237CD3043287B9DB96 Content-Type: message/rfc822; name="Re: const T vs T const.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: const T vs T const.eml"
Path: reader2.panix.com!panix!usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Bo Persson Newsgroups: comp.lang.c++ Subject: Re: const T vs T const Date: Mon, 26 Sep 2016 22:16:02 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 7pzhzj9PjUHQahEkm4VrZAmXDMxg8PsvropWmFHeeemULcTbh+ Cancel-Lock: sha1:8Tq4oMJ44dpphM7h7JEXqu8zgmE= User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 In-Reply-To: Xref: panix comp.lang.c++:1123878
On 2016-09-26 19:50, Stefan Ram wrote: > It was possibly in this newsgroup where the topic > "const T vs T const" was discussed some months ago. > (Or it might have been "comp.lang.c".) > > Dan Sacks famously wrote about it and recommended > "T const" IIRC. > > I now found something new about this topic in the > "Library Design Guidlines" for C++: quote > > const goes in the wrong place, i.e., to the left > > unquote. Thus, they acknowledge what Dan Sacks > wrote by using "wrong", only to then recommend > the opposite, i.e., "left". > > Why? Maybe because tradition dictates this. (No > rationale is given there.) >
Of course there is no rationale, so we have to pick one order. Apparently Bjarne has always preferred "const int i = 0;".
And I have never seen anyone arguing that
constexpr int x = 0;
is the wrong order. So why have different rules for const and constexpr?
Bo Persson
--------------5B238A237CD3043287B9DB96 Content-Type: message/rfc822; name="Re: const T vs T const.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: const T vs T const.eml"
Path: reader2.panix.com!panix!goblin3!goblin.stu.neva.ru!nntp-feed.chiark.greenend.org.uk!ewrotcd!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Alf P. Steinbach" Newsgroups: comp.lang.c++ Subject: Re: const T vs T const Date: Tue, 27 Sep 2016 00:41:46 +0200 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 26 Sep 2016 22:42:51 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="737328bde590e659c1fc5acc416a6973"; logging-data="19154"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX19T7gK3Cci76iQQf/jvHn67" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 In-Reply-To: Cancel-Lock: sha1:Jdrw/I8Scg8MaytO1nqFGfXAao8= Xref: panix comp.lang.c++:1123880
On 26.09.2016 19:50, Stefan Ram wrote: > It was possibly in this newsgroup where the topic > "const T vs T const" was discussed some months ago. > (Or it might have been "comp.lang.c".) > > Dan Sacks famously wrote about it and recommended > "T const" IIRC.
In order to write `const` first, simply define
template< class Type > using Ptr_ = Type*;
Now write e.g.
Ptr_ p;
and
const Ptr_ p;
Easy peasy. :)
Well except for `auto` type deduction, there's a kind of black hole in the language there, but one can live with that.
> I now found something new about this topic in the > "Library Design Guidlines" for C++: quote > > const goes in the wrong place, i.e., to the left > > unquote. Thus, they acknowledge what Dan Sacks > wrote by using "wrong", only to then recommend > the opposite, i.e., "left". > > Why? Maybe because tradition dictates this. (No > rationale is given there.)
Not sure exactly what you're quoting here or what you're asking for rationale about, can you clarify?
Cheers!,
- Alf
--------------5B238A237CD3043287B9DB96 Content-Type: message/rfc822; name="Re: const T vs T const.eml" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="Re: const T vs T const.eml"
--------------5B238A237CD3043287B9DB96 Content-Type: message/rfc822; name="Re: const T vs T const.eml" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="Re: const T vs T const.eml"
Path: reader2.panix.com!panix!bloom-beacon.mit.edu!bloom-beacon.mit.edu!168.235.88.217.MISMATCH!2.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!feeder3.usenet.farm!feeder2.usenet.farm!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Alf P. Steinbach" Newsgroups: comp.lang.c++ Subject: Re: const T vs T const Date: Tue, 27 Sep 2016 05:31:14 +0200 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Tue, 27 Sep 2016 03:32:20 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="737328bde590e659c1fc5acc416a6973"; logging-data="20782"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX1/Qr+a8kvqPr53lmmOjw/lW" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 In-Reply-To: Cancel-Lock: sha1:/Q+01ExQ8qa4kgZqoEVQo7OZohM= Xref: panix comp.lang.c++:1123889
On 27.09.2016 01:34, Stefan Ram wrote: > "Alf P. Steinbach" writes: >> Not sure exactly what you're quoting here or what you're asking for >> rationale about, can you clarify? > > The rationale for the apparent guideline to write > > const int i = 2; > > instead of > > int const i = 2; > > . I was quoting the Library Design Guidelines > (Standard Library Guidelines) from isocpp.org. >
Oh, I understand. Sorry.
Well, standard library work has to follow the conventions already established for the C++ standard. It would be just too much work to change those conventions now. So that's a very direct rationale.
I read ?the wrong place? as an acknowledgment that the original choice, back in the 1990's, was sub-optimal.
But, in modern C++ we don't have to cater to the idiosyncracies of the C declaration syntax.
We can just define a `Ptr_` type builder, and a `Ref_`, and so on.
? ? ?
At first, years ago, I went all the way and also defined `Const_`.
But it's silly to define a new syntax where the current one works.
I found it useful to define a `With_const_like_`, in order to transfer constness from one type to another. But I'm still searching for a better, shorter name for that.
? ? ?
There is also a more radical idea of defining `const` versions of all the basic types and require use of e.g. `Var_` to make something mutable. I don't think this idea can be made practically workable: the confusion would be akin to redefining `+` as `-`. But with this idea
Ptr_ p;
would not compile, because it would declare an uninitialized `int const* const`.
One would have write e.g.
Var_> p;
to get something mutable.
Or
Ptr_> p = &blah;
:)
Cheers!,
- Alf
--------------5B238A237CD3043287B9DB96 Content-Type: message/rfc822; name="Re: const T vs T const.eml" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Re: const T vs T const.eml"
Path: reader2.panix.com!panix!goblin3!goblin.stu.neva.ru!news.roellig-ltd.de!open-news-network.org!border2.nntp.ams1.giganews.com!nntp.giganews.com!buffer2.nntp.ams1.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Tue, 27 Sep 2016 00:51:17 -0500 From: Gareth Owen Newsgroups: comp.lang.c++ Subject: Re: const T vs T const References: Date: Tue, 27 Sep 2016 06:51:17 +0100 Message-ID: <87y42dubze.fsf-at-gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:VKnvxh72m/SEKIcp6HBG1MvWAdA= MIME-Version: 1.0 Content-Type: text/plain X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-KcLbfKUFb8shpC/rbVMNOYu3mu8X8d3Skt+kWADyC1YBZAIM7d38QNXYVL0aosbI3DmJQubszqw5yFS!Kwul1YRFGLrrLgQkFxGXnAEmyQIortEYyhwYmnFcVCusX61u+yNVLZ8EeEAiWN18gvzjZA== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 1231 Xref: panix comp.lang.c++:1123890
ram-at-zedat.fu-berlin.de (Stefan Ram) writes:
> It was possibly in this newsgroup where the topic > "const T vs T const" was discussed some months ago. > (Or it might have been "comp.lang.c".)
As an equally vital followup, how many angels can we fit on the head of a pin?
--------------5B238A237CD3043287B9DB96 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline
_______________________________________________ Learn mailing list Learn-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/learn
--------------5B238A237CD3043287B9DB96--
|
|