Topic: Dynamic Arrays: simple syntax


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sat, 20 Apr 2013 08:56:06 -0700 (PDT)
Raw View
------=_Part_82_3653096.1366473366153
Content-Type: text/plain; charset=ISO-8859-1

*<<I am sorry for posting this in a separate slot, but for some reason my
last two replies have been deleted, for no apparent reason.>>*

Why don't we introduce simple dynamic arrays in objects, which can be
allocated in the same place as the objects (stack or heap) they belong to?
For example, like this:
class A
{
   double x[];
public:
    A(std::size_t n):x(n) {}
   ...
};
The use sizeof(x) will return the size of the pointer (often 4 or 8), the
same as in case
void f(double [] x);


Show trimmed content


--

---
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/?hl=en.



------=_Part_82_3653096.1366473366153
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div><strong>&lt;&lt;I am sorry for posting this in a separate slot, but fo=
r some reason my last two replies have been deleted,&nbsp;for no apparent r=
eason.&gt;&gt;</strong></div><div>&nbsp;</div><div><div style=3D"overflow: =
hidden;"><div>Why don't we introduce simple dynamic arrays in objects, whic=
h can be allocated in the same place as the objects (stack or heap) they be=
long to?</div><div>For example, like this:</div><div>class A<br>{<br>&nbsp;=
&nbsp; double x[];<br>public:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp=
;&nbsp; A(std::size_t n):x(n) {}<br>&nbsp;&nbsp; ...&nbsp;&nbsp; <br>};<br>=
</div><div>The use sizeof(x) will return the size of the pointer (often 4 o=
r 8), the same as in case</div><div>void f(double [] x);</div><div>&nbsp;</=
div><div>&nbsp;</div></div><a class=3D"gwt-Anchor" aria-hidden=3D"true" sty=
le=3D"display: none;">Show trimmed content</a><div>&nbsp;</div><div></div><=
div></div><div style=3D"display: none;"></div><div style=3D"display: none;"=
></div><div style=3D"display: none;"></div><div aria-hidden=3D"false"><div =
class=3D"GHSP2CYBGED"></div></div><div class=3D"GHSP2CYBN2"><div class=3D"G=
HSP2CYBM2 GHSP2CYBGAB" aria-hidden=3D"false"><div><div style=3D"display: in=
line-block;"><div style=3D"display: none;"></div></div> </div></div></div><=
/div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_82_3653096.1366473366153--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sat, 20 Apr 2013 09:26:21 -0700 (PDT)
Raw View
------=_Part_636_15956678.1366475181922
Content-Type: text/plain; charset=ISO-8859-1



On Saturday, April 20, 2013 8:56:06 AM UTC-7, Mikhail Semenov wrote:
>
> *<<I am sorry for posting this in a separate slot, but for some reason my
> last two replies have been deleted, for no apparent reason.>>*
>
> Why don't we introduce simple dynamic arrays in objects, which can be
> allocated in the same place as the objects (stack or heap) they belong to?
> For example, like this:
> class A
> {
>    double x[];
> public:
>     A(std::size_t n):x(n) {}
>    ...
> };
> The use sizeof(x) will return the size of the pointer (often 4 or 8), the
> same as in case
> void f(double [] x);
>

There seems to be a contradiction here. You want `x` to be "allocated in
the same place as the objects (stack or heap) they belong to". *By
definition*, that means that the size of `A` would not be fixed; it would
be based on the size used in the construction of `A::x`. Yet you somehow
want the `sizeof(x)` (and therefore `sizeof(A)`) be a fixed value.

So which is it: allocated in the same place, or just a really bad
`std::vector`?

--

---
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/?hl=en.



------=_Part_636_15956678.1366475181922
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br><br>On Saturday, April 20, 2013 8:56:06 AM UTC-7, Mikhail Semenov wrote=
:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bo=
rder-left: 1px #ccc solid;padding-left: 1ex;"><div><b>&lt;&lt;I am sorry fo=
r posting this in a separate slot, but for some reason my last two replies =
have been deleted,&nbsp;for no apparent reason.&gt;&gt;</b></div><div>&nbsp=
;</div><div><div style=3D"overflow:hidden"><div>Why don't we introduce simp=
le dynamic arrays in objects, which can be allocated in the same place as t=
he objects (stack or heap) they belong to?</div><div>For example, like this=
:</div><div>class A<br>{<br>&nbsp;&nbsp; double x[];<br>public:&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; A(std::size_t n):x(n) {}<br>&nbsp=
;&nbsp; ...&nbsp;&nbsp; <br>};<br></div><div>The use sizeof(x) will return =
the size of the pointer (often 4 or 8), the same as in case</div><div>void =
f(double [] x);</div></div></div></blockquote><div><br>There seems to be a =
contradiction here. You want `x` to be "allocated in the same place as the =
objects (stack or heap) they belong to". <i>By definition</i>, that means t=
hat the size of `A` would not be fixed; it would be based on the size used =
in the construction of `A::x`. Yet you somehow want the `sizeof(x)` (and th=
erefore `sizeof(A)`) be a fixed value.<br><br>So which is it: allocated in =
the same place, or just a really bad `std::vector`?<br></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_636_15956678.1366475181922--

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sat, 20 Apr 2013 19:11:26 +0100
Raw View
--047d7b3442e49c378a04dacec34c
Content-Type: text/plain; charset=ISO-8859-1

I don't think there is any contradiction. The was asked a question about
sizeof(); sizeof() values is defined statically; there is no way to define
dynamically its value.

The idea is that a dynamic array is allocated in the same space and the
object (in the implementation probably just after it). If you use *new, *the
allocation will be on the heap;
if you define the object on the stack (in a block), the array will be
allocated on the stack.

Obviously, there will be issues with copying:
A a1(10);
A a2(10);
A a3(100);
....

You may  write:
a1 = a2;
 But not:
a3 = a1;
The sizes of the dynamically allocated arrays inside objects that you may
copy should be the same.

The basic idea is that dynamically allocated arrays will produce less
fragmented heap.




On 20 April 2013 17:26, Nicol Bolas <jmckesson@gmail.com> wrote:

>
>
> On Saturday, April 20, 2013 8:56:06 AM UTC-7, Mikhail Semenov wrote:
>>
>> *<<I am sorry for posting this in a separate slot, but for some reason
>> my last two replies have been deleted, for no apparent reason.>>*
>>
>> Why don't we introduce simple dynamic arrays in objects, which can be
>> allocated in the same place as the objects (stack or heap) they belong to?
>> For example, like this:
>> class A
>> {
>>    double x[];
>> public:
>>     A(std::size_t n):x(n) {}
>>    ...
>> };
>> The use sizeof(x) will return the size of the pointer (often 4 or 8), the
>> same as in case
>> void f(double [] x);
>>
>
> There seems to be a contradiction here. You want `x` to be "allocated in
> the same place as the objects (stack or heap) they belong to". *By
> definition*, that means that the size of `A` would not be fixed; it would
> be based on the size used in the construction of `A::x`. Yet you somehow
> want the `sizeof(x)` (and therefore `sizeof(A)`) be a fixed value.
>
> So which is it: allocated in the same place, or just a really bad
> `std::vector`?
>
> --
>
> ---
> 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/?hl=en.
>
>
>

--

---
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/?hl=en.



--047d7b3442e49c378a04dacec34c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I don&#39;t think there is any contradiction. The was=
 asked a question about sizeof(); sizeof() values is defined statically; th=
ere is no way to define dynamically its value.</div><div>=A0</div><div>The =
idea is that=A0a dynamic=A0array is allocated in the same space and the obj=
ect (in the implementation probably just after it). If you use <strong>new,=
 </strong>the allocation will be on the heap;</div>
<div>if you define the object on the stack (in a block), the array will be =
allocated on the stack. </div><div>=A0</div><div>Obviously, there will be i=
ssues with copying: </div><div>A a1(10);</div><div>A a2(10);</div><div>A a3=
(100);</div>
<div>...</div><div>=A0</div><div>You may=A0 write:</div><div>a1 =3D a2;</di=
v><div>=A0But not:</div><div>a3 =3D a1;</div><div>The sizes of the dynamica=
lly allocated arrays inside objects that you may copy should be the same.</=
div><div>
=A0</div><div>The basic idea is that dynamically allocated arrays will prod=
uce less fragmented heap.</div><div>=A0</div><div>=A0</div></div><div class=
=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On 20 April 2013 17:26,=
 Nicol Bolas <span dir=3D"ltr">&lt;<a href=3D"mailto:jmckesson@gmail.com" t=
arget=3D"_blank">jmckesson@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div class=3D"im"><br><br>On Saturday, April=
 20, 2013 8:56:06 AM UTC-7, Mikhail Semenov wrote:<blockquote class=3D"gmai=
l_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-col=
or:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
<div><b>&lt;&lt;I am sorry for posting this in a separate slot, but for som=
e reason my last two replies have been deleted,=A0for no apparent reason.&g=
t;&gt;</b></div><div>=A0</div><div><div style=3D"overflow:hidden"><div>Why =
don&#39;t we introduce simple dynamic arrays in objects, which can be alloc=
ated in the same place as the objects (stack or heap) they belong to?</div>
<div>For example, like this:</div><div>class A<br>{<br>=A0=A0 double x[];<b=
r>public:=A0=A0=A0=A0=A0 <br>=A0=A0=A0 A(std::size_t n):x(n) {}<br>=A0=A0 .=
...=A0=A0 <br>};<br></div><div>The use sizeof(x) will return the size of the=
 pointer (often 4 or 8), the same as in case</div>
<div>void f(double [] x);</div></div></div></blockquote></div><div><br>Ther=
e seems to be a contradiction here. You want `x` to be &quot;allocated in t=
he same place as the objects (stack or heap) they belong to&quot;. <i>By de=
finition</i>, that means that the size of `A` would not be fixed; it would =
be based on the size used in the construction of `A::x`. Yet you somehow wa=
nt the `sizeof(x)` (and therefore `sizeof(A)`) be a fixed value.<br>
<br>So which is it: allocated in the same place, or just a really bad `std:=
:vector`?<br></div><div class=3D"HOEnZb"><div class=3D"h5">

<p></p>

-- <br>
=A0<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%2Bunsubscribe@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/?hl=3Den" target=3D"_blank">http://groups.google.com/a/isocpp=
..org/group/std-proposals/?hl=3Den</a>.<br>
=A0<br>
=A0<br>
</div></div></blockquote></div><br></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

--047d7b3442e49c378a04dacec34c--

.


Author: DeadMG <wolfeinstein@gmail.com>
Date: Sat, 20 Apr 2013 11:39:08 -0700 (PDT)
Raw View
------=_Part_779_4501296.1366483148988
Content-Type: text/plain; charset=ISO-8859-1

So, just to summarize:

   - You want a sizeof() that doesn't actually represent the size of the
   object.
   - You want operator= to be enabled or disabled based on a run-time
   variable.

Neither of these are possible.

--

---
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/?hl=en.



------=_Part_779_4501296.1366483148988
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

So, just to summarize:<div><ul><li><span style=3D"line-height: normal;">You=
 want a sizeof() that doesn't actually represent the size of the object.</s=
pan></li><li><span style=3D"line-height: normal;">You want operator=3D to b=
e enabled or disabled based on a run-time variable.</span></li></ul><div>Ne=
ither of these are possible.</div></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_779_4501296.1366483148988--

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sat, 20 Apr 2013 19:51:09 +0100
Raw View
--001a11c2029aa8a9bf04dacf5165
Content-Type: text/plain; charset=ISO-8859-1

If you define
void f(double a []);
the sizeof(a) does not mean much either.

The operator= is not defined for arrays properly anyway (it compares
pointers).

But if you want, you can define operator= for the class and create size()
member inside the class.

Why use complexity where it should not be?



On 20 April 2013 19:39, DeadMG <wolfeinstein@gmail.com> wrote:

> So, just to summarize:
>
>    - You want a sizeof() that doesn't actually represent the size of the
>    object.
>    - You want operator= to be enabled or disabled based on a run-time
>    variable.
>
> Neither of these are possible.
>
> --
>
> ---
> 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/?hl=en.
>
>
>

--

---
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/?hl=en.



--001a11c2029aa8a9bf04dacf5165
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>If you define</div><div>void f(double a []);</div><di=
v>the sizeof(a) does not mean much either.</div><div>=A0</div><div>The oper=
ator=3D is not defined for arrays properly anyway (it compares pointers).</=
div>
<div>=A0</div><div>But if you want, you can define operator=3D for the clas=
s and create size() member inside the class.</div><div>=A0</div><div>Why us=
e complexity where it should not be?</div><div>=A0</div></div><div class=3D=
"gmail_extra">
<br><br><div class=3D"gmail_quote">On 20 April 2013 19:39, DeadMG <span dir=
=3D"ltr">&lt;<a href=3D"mailto:wolfeinstein@gmail.com" target=3D"_blank">wo=
lfeinstein@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex=
">
So, just to summarize:<div><ul><li><span style=3D"line-height:normal">You w=
ant a sizeof() that doesn&#39;t actually represent the size of the object.<=
/span></li><li><span style=3D"line-height:normal">You want operator=3D to b=
e enabled or disabled based on a run-time variable.</span></li>
</ul><div>Neither of these are possible.</div></div><div class=3D"HOEnZb"><=
div class=3D"h5">

<p></p>

-- <br>
=A0<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%2Bunsubscribe@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/?hl=3Den" target=3D"_blank">http://groups.google.com/a/isocpp=
..org/group/std-proposals/?hl=3Den</a>.<br>
=A0<br>
=A0<br>
</div></div></blockquote></div><br></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

--001a11c2029aa8a9bf04dacf5165--

.


Author: Jens Maurer <Jens.Maurer@gmx.net>
Date: Sat, 20 Apr 2013 21:12:19 +0200
Raw View
On 04/20/2013 08:51 PM, Mikhail Semenov wrote:
> If you define
> void f(double a []);
> the sizeof(a) does not mean much either.

Since the array decays to a pointer, it's the size of a pointer.

> The operator= is not defined for arrays properly anyway (it compares pointers).

Are you talking about operator= or operator==?  These are different.

> But if you want, you can define operator= for the class and create size() member inside the class.

Did you look at the runtime-size arrays and dynarray proposals?

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3532.html
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3497.html

They cover as much ground as is feasible, I believe.

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/?hl=en.



.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sat, 20 Apr 2013 20:32:03 +0100
Raw View
--001a11c20b82ed474904dacfe371
Content-Type: text/plain; charset=ISO-8859-1

Hello Jens,

I looked at it. My concern is that the dynamic arrays it's just another
container. I think the syntax should be much simpler. And then if somebody
wants they can implement
classes around it.  How many array containers do we need?

As for runtime-sized arrays (N3497) they are implemented on the stack. You
cannot use them as object members, which is a shame. I think they should be
allowed primarily as object members.
The N3497 proposal closely follows C Standard (with some omissions).

Regards,
Mikhail.


On 20 April 2013 20:12, Jens Maurer <Jens.Maurer@gmx.net> wrote:

> On 04/20/2013 08:51 PM, Mikhail Semenov wrote:
> > If you define
> > void f(double a []);
> > the sizeof(a) does not mean much either.
>
> Since the array decays to a pointer, it's the size of a pointer.
>
> > The operator= is not defined for arrays properly anyway (it compares
> pointers).
>
> Are you talking about operator= or operator==?  These are different.
>
> > But if you want, you can define operator= for the class and create
> size() member inside the class.
>
> Did you look at the runtime-size arrays and dynarray proposals?
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3532.html
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3497.html
>
> They cover as much ground as is feasible, I believe.
>
> 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/?hl=en.
>
>
>

--

---
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/?hl=en.



--001a11c20b82ed474904dacfe371
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hello Jens,</div><div>=A0</div><div>I looked at it. M=
y concern is that the dynamic arrays it&#39;s just another container. I thi=
nk the syntax should be much simpler. And then if somebody wants they can i=
mplement</div>
<div>classes around it.=A0 How many array containers do we need?</div><div>=
=A0</div><div>As for runtime-sized arrays (N3497) they are implemented on t=
he stack. You cannot use them as object members, which is a shame. I think =
they should be allowed primarily as object members.</div>
<div>The N3497 proposal closely follows C Standard (with some omissions).</=
div><div>=A0</div><div>Regards,</div><div>Mikhail.</div></div><div class=3D=
"gmail_extra"><br><br><div class=3D"gmail_quote">On 20 April 2013 20:12, Je=
ns Maurer <span dir=3D"ltr">&lt;<a href=3D"mailto:Jens.Maurer@gmx.net" targ=
et=3D"_blank">Jens.Maurer@gmx.net</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div class=3D"im">On 04/20/2013 08:51 PM, Mi=
khail Semenov wrote:<br>
&gt; If you define<br>
&gt; void f(double a []);<br>
&gt; the sizeof(a) does not mean much either.<br>
<br>
</div>Since the array decays to a pointer, it&#39;s the size of a pointer.<=
br>
<div class=3D"im"><br>
&gt; The operator=3D is not defined for arrays properly anyway (it compares=
 pointers).<br>
<br>
</div>Are you talking about operator=3D or operator=3D=3D? =A0These are dif=
ferent.<br>
<div class=3D"im"><br>
&gt; But if you want, you can define operator=3D for the class and create s=
ize() member inside the class.<br>
<br>
</div>Did you look at the runtime-size arrays and dynarray proposals?<br>
<br>
<a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3532.ht=
ml" target=3D"_blank">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/20=
13/n3532.html</a><br>
<a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3497.ht=
ml" target=3D"_blank">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/20=
13/n3497.html</a><br>
<br>
They cover as much ground as is feasible, I believe.<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
Jens<br>
</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
--<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%2Bunsubscribe@isocpp.org">std-propo=
sals+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/?hl=3Den" target=3D"_blank">http://groups.google.com/a/isocpp=
..org/group/std-proposals/?hl=3Den</a>.<br>
<br>
<br>
</div></div></blockquote></div><br></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

--001a11c20b82ed474904dacfe371--

.


Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@gmail.com>
Date: Sat, 20 Apr 2013 21:36:12 +0200
Raw View
2013/4/20 Mikhail Semenov <mikhailsemenov1957@gmail.com>:
[..]
> The idea is that a dynamic array is allocated in the same space and the
> object (in the implementation probably just after it). If you use new, the
> allocation will be on the heap;
> if you define the object on the stack (in a block), the array will be
> allocated on the stack.
>
> Obviously, there will be issues with copying:
> A a1(10);
> A a2(10);
> A a3(100);
> ...
>
> You may  write:
> a1 = a2;
>  But not:
> a3 = a1;

Let me add that the accepted dynarray proposal will not allow copies
of dynarray just for this reason and is also not
default-constructible, because it could not be filled later.

- Daniel

--

---
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/?hl=en.



.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sat, 20 Apr 2013 12:58:38 -0700 (PDT)
Raw View
------=_Part_405_25498625.1366487919073
Content-Type: text/plain; charset=ISO-8859-1

The sizeof() is statically defined; there is no way to define it properly
dynamically.
It is possible to forbid the assignment altogether, but the efficiency will
be lost in some cases.

Another approach is not to allow default assignment, but to allow operator=
to be defined by the user, which may check for the sizes (sizes can be
stored as class members) and produce an exception when they don't match.
Anyway, these are the details that can be addressed.


On Saturday, April 20, 2013 7:39:08 PM UTC+1, DeadMG wrote:

> So, just to summarize:
>
>    - You want a sizeof() that doesn't actually represent the size of the
>    object.
>    - You want operator= to be enabled or disabled based on a run-time
>    variable.
>
> Neither of these are possible.
>

--

---
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/?hl=en.



------=_Part_405_25498625.1366487919073
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div>The sizeof() is statically defined; there is no way to define it prope=
rly dynamically.</div><div>It is possible to forbid the assignment altogeth=
er, but the efficiency will be lost in some cases.</div><div>&nbsp;</div><d=
iv>Another approach is not to allow default assignment, but to allow operat=
or=3D to be defined by the user, which may check for the sizes (sizes can b=
e stored as class members) and produce an exception when they don't match.<=
/div><div>Anyway, these are the details that can be addressed. </div><div>&=
nbsp;</div><div><br>On Saturday, April 20, 2013 7:39:08 PM UTC+1, DeadMG wr=
ote:</div><blockquote 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-style: solid;">So, just to summarize:<div><ul><li><=
span style=3D"line-height: normal;">You want a sizeof() that doesn't actual=
ly represent the size of the object.</span></li><li><span style=3D"line-hei=
ght: normal;">You want operator=3D to be enabled or disabled based on a run=
-time variable.</span></li></ul><div>Neither of these are possible.</div></=
div></blockquote>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_405_25498625.1366487919073--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sat, 20 Apr 2013 13:55:42 -0700 (PDT)
Raw View
------=_Part_763_10046033.1366491342985
Content-Type: text/plain; charset=ISO-8859-1

On Saturday, April 20, 2013 12:32:03 PM UTC-7, Mikhail Semenov wrote:
>
> Hello Jens,
>
> I looked at it. My concern is that the dynamic arrays it's just another
> container. I think the syntax should be much simpler. And then if somebody
> wants they can implement
> classes around it.
>

Your idea requires that the compiler effectively implement what an object
could and should be implementing. You're basically forcing the compiler to
do the job of a library component. All just so that you can use `[]` syntax.

I point this out because this `[]` syntax does not let you get at the *size*of the array. Ever. So you can't even use range-based for with them, let
alone any other algorithm unless you happen to know the size of the array.
You can't pass them as parameters without passing the size. And so on.

In short... it is inferior to the object version in pretty much every
possible way, except *maybe* for its declaration syntax.

Explicit objects are the right way to go. They're far easier to implement,
and it's far more obvious what's going on than a language modification.

  How many array containers do we need?
>

Four. One for each use case for arrays:

1: Variable resizing (ie: std::vector)
2: Fixed, runtime size with heap-allocated storage, with all the rights and
responsibilities thereof (ie: guaranteed fast move support).
3: Fixed, runtime size, stack-allocated (can't move).
4: Fixed, compile-time size (ie: std::array)

Your idea only covers case 3 (since it doesn't have fast move support).

I would rather #3 and #2 be separate objects, and that #3 be restricted to
only working when used as part of the stack.

--

---
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/?hl=en.



------=_Part_763_10046033.1366491342985
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Saturday, April 20, 2013 12:32:03 PM UTC-7, Mikhail Semenov wrote:<block=
quote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-le=
ft: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>Hello Jens,</d=
iv><div>&nbsp;</div><div>I looked at it. My concern is that the dynamic arr=
ays it's just another container. I think the syntax should be much simpler.=
 And then if somebody wants they can implement</div>
<div>classes around it.</div></div></blockquote><div><br>Your idea requires=
 that the compiler effectively implement what an object could and should be=
 implementing. You're basically forcing the compiler to do the job of a lib=
rary component. All just so that you can use `[]` syntax.<br><br>I point th=
is out because this `[]` syntax does not let you get at the <i>size</i> of =
the array. Ever. So you can't even use range-based for with them, let alone=
 any other algorithm unless you happen to know the size of the array. You c=
an't pass them as parameters without passing the size. And so on.<br><br>In=
 short... it is inferior to the object version in pretty much every possibl=
e way, except <i>maybe</i> for its declaration syntax.<br><br>Explicit obje=
cts are the right way to go. They're far easier to implement, and it's far =
more obvious what's going on than a language modification.<br><br></div><bl=
ockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border=
-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>&nbsp; How =
many array containers do we need?</div></div></blockquote><div><br>Four. On=
e for each use case for arrays:<br><br>1: Variable resizing (ie: std::vecto=
r)<br>2: Fixed, runtime size with heap-allocated storage, with all the righ=
ts and responsibilities thereof (ie: guaranteed fast move support).<br>3: F=
ixed, runtime size, stack-allocated (can't move).<br>4: Fixed, compile-time=
 size (ie: std::array)<br><br>Your idea only covers case 3 (since it doesn'=
t have fast move support).<br><br>I would rather #3 and #2 be separate obje=
cts, and that #3 be restricted to only working when used as part of the sta=
ck.<br></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_763_10046033.1366491342985--

.