On 2015-02-05 at 09:58, bearophile wrote:
zhmt:
Will arr.ptr change in the future?
As the array add more members , it need more memroy, then remalloc may be
called, the pointer maybe change, then the stored pointer will be invalid.
Will this happen?
Yes, it can happen.
Therefore, don't
The behavior of array is more or less unpredictable.
If it is always a reference like class , it will be more
predictable.
Sorry, I misunderstand the meaning of array pointer, it is not
equals to arr.ptr.
The array pointer meets my need perfectly .
Ignore my replies above, Sorry!!!
Will arr.ptr change in the future?
As the array add more members , it need more memroy, then
remalloc may be called, the pointer maybe change, then the stored
pointer will be invalid.
Will this happen?
zhmt:
Will arr.ptr change in the future?
As the array add more members , it need more memroy, then
remalloc may be called, the pointer maybe change, then the
stored pointer will be invalid.
Will this happen?
Yes, it can happen.
Bye,
bearophile
On Thursday, 5 February 2015 at 08:58:47 UTC, bearophile wrote:
zhmt:
Will arr.ptr change in the future?
As the array add more members , it need more memroy, then
remalloc may be called, the pointer maybe change, then the
stored pointer will be invalid.
Will this happen?
Yes, it can
On Thursday, 5 February 2015 at 06:58:09 UTC, Ali Çehreli wrote:
On 02/04/2015 10:42 PM, zhmt wrote:
Here is a simple code snippet:
With this approach, the allocation of `arr` itself is often
clumsy and error-prone. In this case it is important to note that
`arr` is allocated on the stack
Ali Çehreli acehr...@yahoo.com schrieb im Newsbeitrag
news:mav4a1$l3a$1...@digitalmars.com...
On 02/04/2015 10:42 PM, zhmt wrote:
The following article is very informative:
http://dlang.org/d-array-article.html
Nice and important article.
But: How could I have looked this up this myself?
On Thursday, 5 February 2015 at 10:12:47 UTC, wrote:
On Thursday, 5 February 2015 at 06:58:09 UTC, Ali Çehreli wrote:
On 02/04/2015 10:42 PM, zhmt wrote:
Here is a simple code snippet:
With this approach, the allocation of `arr` itself is often
clumsy and error-prone. In this case it is
On 02/05/2015 01:49 AM, Christof Schardt wrote:
Ali Çehreli acehr...@yahoo.com schrieb im Newsbeitrag
news:mav4a1$l3a$1...@digitalmars.com...
On 02/04/2015 10:42 PM, zhmt wrote:
The following article is very informative:
http://dlang.org/d-array-article.html
Nice and important article.
On 02/04/2015 10:42 PM, zhmt wrote:
Here is a simple code snippet:
class A {
public int[] arr;
}
class B {
public int[] arr;
}
void main()
{
int[] arr;
A a = new A;
B b = new B;
a.arr = arr;
b.arr = arr;
arr ~= 1;
arr ~= -2;
foreach(data;
void test(ref int[] arr) {
arr ~= 4;
}
It is something like ref variables. But ref just be used in
function declaration.
@Ali
I know the direction now, I should learn more about the pointers.
Thx very much.
Here is a simple code snippet:
class A {
public int[] arr;
}
class B {
public int[] arr;
}
void main()
{
int[] arr;
A a = new A;
B b = new B;
a.arr = arr;
b.arr = arr;
arr ~= 1;
arr ~= -2;
foreach(data; a.arr)
14 matches
Mail list logo