220 19952 <CAOfiQqnohbBZt9OguvL8Tg=9cDPzEzTPC_hAkdErM9T_mnH6vw@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Richard Smith <richard@metafoo.co.uk>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Address of a reference: determining the value
 category of what it refers?
Date: Fri, 21 Aug 2015 18:14:47 -0700
Lines: 233
Approved: news@gmane.org
Message-ID: <CAOfiQqnohbBZt9OguvL8Tg=9cDPzEzTPC_hAkdErM9T_mnH6vw@mail.gmail.com>
References: <76fe342f-3342-4355-af20-1c41b21e54aa@isocpp.org>
	<CANh8DEk8mVDWksjmej6BbHw3GH0Rhqfp0XpQq2RORtj6fcDHXw@mail.gmail.com>
	<1115b787-4cfd-4052-9f49-ece9c4bdf2ec@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=bcaec51d225441a9de051ddc1cf0
X-Trace: ger.gmane.org 1440206092 3094 80.91.229.3 (22 Aug 2015 01:14:52 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 22 Aug 2015 01:14:52 +0000 (UTC)
To: "std-proposals@isocpp.org" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDVNBJG4YAIBBCE236XAKGQEHZKNK3Q@isocpp.org Sat Aug 22 03:14:52 2015
Return-path: <std-proposals+bncBDVNBJG4YAIBBCE236XAKGQEHZKNK3Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pa0-f69.google.com ([209.85.220.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDVNBJG4YAIBBCE236XAKGQEHZKNK3Q@isocpp.org>)
	id 1ZSxOU-0008H6-Ey
	for gclcip-std-proposals@m.gmane.org; Sat, 22 Aug 2015 03:14:50 +0200
Original-Received: by pacgr6 with SMTP id gr6sf14626309pac.3
        for <gclcip-std-proposals@m.gmane.org>; Fri, 21 Aug 2015 18:14:49 -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:sender:in-reply-to:references:date
         :message-id:subject:from:to:content-type: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=do1hgZYI8SKLLLtYZqOaHfQweHPjrV56i+5qMPgigmc=;
        b=MAcRIFYm2i7Lv/KBSSaX3tGIeocpHF6ea70PGtCY8dULTXAZooZ2aAt9b9Ce5wwpxO
         MinOjV+pTi1Yboy3uZK2/gg2ArgGE6/rUZk+5WZ5pUzwoS7LttNsoJhWY4gPfbLfxgHk
         O22b9Wds0fwqpvZd388e/Ur+z2Kmz0fVG/uBJJPhQ0drpAriyPpL4x4bJMcywathCNm1
         KB7dq5aAd6/MUbI4Yj10poYsDkIiTJjz2yCm81ytv6KgvPjchDG8KumEdQ8UDgZCEaak
         OQH/1IkiM7gJ1qDuaBByNxqwb+749Srh8uQ2/F61cdhfcwh/Lk6lHdUYrw3gQCGexLLr
         2yxA==
X-Gm-Message-State: ALoCoQk0V1Z0gZnurNn+U+SI6HSmvGsk32AIoWrhk/XQexWUi10R5aqVq7U7GY8z5n7SsUknEL7F
X-Received: by 10.66.163.162 with SMTP id yj2mr8805557pab.27.1440206088962;
        Fri, 21 Aug 2015 18:14:48 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.29.137 with SMTP id k9ls1774981obh.81.gmail; Fri, 21 Aug
 2015 18:14:48 -0700 (PDT)
X-Received: by 10.53.12.229 with SMTP id et5mr13871349vdd.73.1440206088128;
        Fri, 21 Aug 2015 18:14:48 -0700 (PDT)
Original-Received: from mail-vk0-x235.google.com (mail-vk0-x235.google.com. [2607:f8b0:400c:c05::235])
        by mx.google.com with ESMTPS id yr14si13082410vdb.81.2015.08.21.18.14.47
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 21 Aug 2015 18:14:48 -0700 (PDT)
Received-SPF: pass (google.com: domain of metafoo@gmail.com designates 2607:f8b0:400c:c05::235 as permitted sender) client-ip=2607:f8b0:400c:c05::235;
Original-Received: by vkm66 with SMTP id 66so38008309vkm.1
        for <std-proposals@isocpp.org>; Fri, 21 Aug 2015 18:14:47 -0700 (PDT)
X-Received: by 10.52.30.136 with SMTP id s8mr13926041vdh.38.1440206087627;
 Fri, 21 Aug 2015 18:14:47 -0700 (PDT)
Original-Sender: metafoo@gmail.com
Original-Received: by 10.31.237.70 with HTTP; Fri, 21 Aug 2015 18:14:47 -0700 (PDT)
In-Reply-To: <1115b787-4cfd-4052-9f49-ece9c4bdf2ec@isocpp.org>
X-Original-Sender: richard@metafoo.co.uk
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of metafoo@gmail.com designates 2607:f8b0:400c:c05::235 as permitted
 sender) smtp.mailfrom=metafoo@gmail.com;       dkim=pass header.i=@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: <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>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:19952
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19952>

--bcaec51d225441a9de051ddc1cf0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Fri, Aug 21, 2015 at 5:52 PM, NDos Dannyu <ndospark320@naver.com> wrote:

>
>
> 2015=EB=85=84 8=EC=9B=94 22=EC=9D=BC =ED=86=A0=EC=9A=94=EC=9D=BC =EC=98=
=A4=EC=A0=84 8=EC=8B=9C 49=EB=B6=84 45=EC=B4=88 UTC+9, Matt Calabrese =EB=
=8B=98=EC=9D=98 =EB=A7=90:
>
>> Taking the address of an object in C++ doesn't yield a null pointer, and
>> users should be able to dereference the address of an object to retrieve
>> the original value.
>>
> A reference ISN'T an object; it is, literally, a reference to an object.
> But *const int &rcr(0)* doesn't refer to an object. It refers to zero,
> which isn't an object. Zero doesn't have an address, so rcr should also n=
ot
> have an address.
>

That's not correct. "const int &rcr(0)" implicitly creates a temporary
object of type int and binds the reference to that object. (The reference
binding then extends the lifetime of that temporary object to the lifetime
of the reference.)


> This also wouldn't really be implementable anyway
>
> I thought the compiler would know what a reference is and what the
> reference refers to. Isn't it implementable built-in then...?
>
>>  since soon as you introduce a level of indirection by passing the objec=
t
>> by reference to a function, you'd no longer know that it referred to a
>> literal
>
> I don't get it. For example:
>     *int &foor(int &r) {*
> *        return r;*
> *    }*
> *    const int &foocr(const int &rc) {*
> *        return cr;*
> *    }*
>     *int &&foorr(int &&rr) {*
> *        return rr;*
> *    }*
> *    int main() {*
> *        int i(0);*
> *        foor(i); // OK*
> *        // foor(0); // error: r can't be initialized with 0*
> *        foocr(i); // OK*
> *        foocr(0); // OK*
> *        // foorr(i); // error: rr can't be initialized with i*
> *        foorr(0); // OK*
> *    }*
> A function every argument is initialized when it is called; the function
> well-knows what its arguments exactly are. No problem.
>
> My original intentions were:
>
> I have a value class indicating a finite discrete random variable.
> But I had a problem. For example, assume that I have a variable named X.
> But how can P(X<X=C2=B2) interpreted? X is still X, even it is squared, i=
sn't
> it?
> Things will get much more complicated if I have multiple variables, X, Y
> and Z,
> and I have to do like P(X<X=C2=B2=3DY>|Z|) or something.
> So I decided to make a bind of variables.
> It would be a tree structure, consisting of other binds or variables.
> If it consists of references of variables, it will know what variables ar=
e
> same(or dependant) and what variables are different(or indepentant).
> But how can I deal with rvalues? For examples, 1 can be seen as a variabl=
e
> which is always 1.
> But it has no name. It is just 1. It is always indepentant from
> other variables.
> So I made it to consist of const lvalue references,
> which can initialized with lvalue or rvalue.
> But how can I determine it refers to lvalue or rvalue?? I couldn't find
> any solution from the standard library.
>
>
>
>
>
>
> --
>
> ---
> 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/.
>

--=20

---=20
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 e=
mail 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-proposa=
ls/.

--bcaec51d225441a9de051ddc1cf0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On F=
ri, Aug 21, 2015 at 5:52 PM, NDos Dannyu <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:ndospark320@naver.com" target=3D"_blank">ndospark320@naver.com</a>&gt=
;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 =
..8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><br>=
2015=EB=85=84 8=EC=9B=94 22=EC=9D=BC =ED=86=A0=EC=9A=94=EC=9D=BC =EC=98=A4=
=EC=A0=84 8=EC=8B=9C 49=EB=B6=84 45=EC=B4=88 UTC+9, Matt Calabrese =EB=8B=
=98=EC=9D=98 =EB=A7=90:<span class=3D""><br><blockquote class=3D"gmail_quot=
e" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb=
(204,204,204);border-left-width:1px;border-left-style:solid"><div dir=3D"lt=
r"><div><div class=3D"gmail_quote"><div>Taking the address of an object in =
C++ doesn&#39;t yield a null pointer, and users should be able to dereferen=
ce the address of an object to retrieve the original value. </div></div></d=
iv></div></blockquote></span><div>A reference ISN&#39;T an object; it is, l=
iterally, a reference to an object.</div><div>But <strong>const int &amp;rc=
r(0)</strong> doesn&#39;t refer to an object. It refers to zero, which isn&=
#39;t an object. Zero doesn&#39;t have an address, so rcr should also not h=
ave an address.</div></div></blockquote><div><br></div><div>That&#39;s not =
correct. &quot;const int &amp;rcr(0)&quot; implicitly creates a temporary o=
bject of type int and binds the reference to that object. (The reference bi=
nding then extends the lifetime of that temporary object to the lifetime of=
 the reference.)</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div =
dir=3D"ltr"><span class=3D""><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);b=
order-left-width:1px;border-left-style:solid">This also wouldn&#39;t really=
 be implementable anyway</blockquote></span><div>I thought the compiler wou=
ld know what=C2=A0a=C2=A0reference is and what the reference refers to. Isn=
&#39;t=C2=A0it implementable built-in then...?</div><span class=3D""><block=
quote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:=
1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-st=
yle:solid">=C2=A0since soon as you introduce a level of indirection by pass=
ing the object by reference to a function, you&#39;d no longer know that it=
 referred to a literal</blockquote></span><div>I don&#39;t get it.=C2=A0For=
 example:</div><div>=C2=A0=C2=A0=C2=A0=C2=A0<strong>int=C2=A0&amp;foor(int =
&amp;r) {</strong></div><div><strong>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 return r;</strong></div><div><strong>=C2=A0=C2=A0=C2=A0 }</strong></=
div><div><strong>=C2=A0=C2=A0=C2=A0 const int &amp;foocr(const int &amp;rc)=
 {</strong></div><div><strong>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 re=
turn cr;</strong></div><div><strong>=C2=A0=C2=A0=C2=A0 }</strong></div><div=
>=C2=A0=C2=A0=C2=A0 <strong>int &amp;&amp;foorr(int &amp;&amp;rr) {</strong=
></div><div><strong>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return rr;</=
strong></div><div><strong>=C2=A0=C2=A0=C2=A0 }</strong></div><div><strong>=
=C2=A0=C2=A0=C2=A0 int main() {</strong></div><div><strong>=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 int i(0);</strong></div><div><strong>=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 foor(i); // OK</strong></div><div><strong=
>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // foor(0); // error: r can&#39=
;t be initialized with 0</strong></div><div><strong>=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 foocr(i); // OK</strong></div><div><strong>=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 foocr(0); // OK</strong></div><div><stron=
g>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // foorr(i); // error: rr can&=
#39;t be initialized with i</strong></div><div><strong>=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 foorr(0); // OK</strong></div><div><strong>=C2=A0=
=C2=A0=C2=A0 }</strong></div><div>A function every argument is initialized =
when it is called; the function well-knows what its arguments exactly are. =
No problem.</div><div><br></div><div>My original intentions were:</div><blo=
ckquote style=3D"margin-right:0px" dir=3D"ltr"><div><font color=3D"#000000"=
>I have a value class indicating a finite discrete random variable.</font><=
/div><div>But I had a problem. For example, assume that=C2=A0I have a varia=
ble named X.</div><div>But=C2=A0how=C2=A0can=C2=A0P(X&lt;X=C2=B2) interpret=
ed? X is still X, even it is squared, isn&#39;t it?</div><div>Things will g=
et much more complicated if=C2=A0I have multiple variables, X, Y and Z,</di=
v><div>and I have to do like P(X&lt;X=C2=B2=3DY&gt;|Z|) or something.=C2=A0=
</div><div>So I decided to=C2=A0make a bind of variables.</div><div>It woul=
d be a tree structure, consisting of=C2=A0other=C2=A0binds=C2=A0or variable=
s.</div><div>If=C2=A0it=C2=A0consists=C2=A0of references of variables, it w=
ill know what variables are same(or dependant) and=C2=A0what variables are =
different(or indepentant).</div><div>But=C2=A0how can I deal with rvalues?=
=C2=A0For examples, 1 can be seen as a variable which is always 1.</div><di=
v>But it has=C2=A0no name. It is just 1. It=C2=A0is always indepentant from=
 other=C2=A0variables.</div><div>So I=C2=A0made it=C2=A0to consist of const=
 lvalue references, which=C2=A0can=C2=A0initialized=C2=A0with lvalue or rva=
lue.</div><div>But=C2=A0how can I determine it=C2=A0refers to lvalue or rva=
lue?? I couldn&#39;t find any solution from the standard library.=C2=A0</di=
v></blockquote><blockquote style=3D"margin-right:0px" dir=3D"ltr"><div>=C2=
=A0</div><div>=C2=A0</div><div>=C2=A0</div><div>=C2=A0</div></blockquote><b=
lockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-l=
eft:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-lef=
t-style:solid"></blockquote></div><div class=3D"HOEnZb"><div class=3D"h5">

<p></p>

-- <br>
<br>
--- <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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>

<p></p>

-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--bcaec51d225441a9de051ddc1cf0--

.
