Heap allocation and internal pointers

2014-01-19 Thread monarch_dodra
What is the "stance" on objects that reside on the heap, and internal pointers? I understand that for stack objects, it leads to data corruption, due to data being bit-moved when passed around. But what about heap data? Currently, our GC doesn't move data around, but what if it did? Would in

Re: Heap allocation and internal pointers

2014-01-19 Thread Andrei Alexandrescu
On 1/19/14 8:18 AM, monarch_dodra wrote: What is the "stance" on objects that reside on the heap, and internal pointers? I understand that for stack objects, it leads to data corruption, due to data being bit-moved when passed around. But what about heap data? Currently, our GC doesn't move dat

Re: Heap allocation and internal pointers

2014-01-20 Thread Dicebot
Quick dlang.org investigation has found this: http://dlang.org/phobos/std_exception.html#.pointsTo Note: Evaluating pointsTo(x, x) checks whether x has internal pointers. This should only be done as an assertive test, as the language is free to assume objects don't have internal pointers (TDPL

Re: Heap allocation and internal pointers

2014-01-20 Thread Dmitry Olshansky
20-Jan-2014 20:35, Dmitry Olshansky пишет: 19-Jan-2014 20:18, monarch_dodra пишет: My usecase is pretty trivial: A linked list. This is often implemented as a "single" sentinel that serves as both pre-head/post-tail. When the list is empty, the sentinel simply points to itself. You could us

Re: Heap allocation and internal pointers

2014-01-20 Thread Dmitry Olshansky
19-Jan-2014 20:18, monarch_dodra пишет: What is the "stance" on objects that reside on the heap, and internal pointers? I understand that for stack objects, it leads to data corruption, due to data being bit-moved when passed around. But what about heap data? Currently, our GC doesn't move data

Re: Heap allocation and internal pointers

2014-01-20 Thread monarch_dodra
On Monday, 20 January 2014 at 12:27:41 UTC, Dicebot wrote: Quick dlang.org investigation has found this: http://dlang.org/phobos/std_exception.html#.pointsTo Note: Evaluating pointsTo(x, x) checks whether x has internal pointers. This should only be done as an assertive test, as the language

Re: Heap allocation and internal pointers

2014-01-20 Thread monarch_dodra
On Monday, 20 January 2014 at 16:35:26 UTC, Dmitry Olshansky wrote: You could use internal pointers for this case as long as: a) The struct will never get copied and/or moved. No pass by value, only pointers. b) It's out of GC control and in particular GC-allocated built-in arrays. This means

Re: Heap allocation and internal pointers

2014-01-20 Thread Steven Schveighoffer
On Mon, 20 Jan 2014 14:22:34 -0500, monarch_dodra wrote: On Monday, 20 January 2014 at 12:27:41 UTC, Dicebot wrote: Quick dlang.org investigation has found this: http://dlang.org/phobos/std_exception.html#.pointsTo Note: Evaluating pointsTo(x, x) checks whether x has internal pointers. Thi

Re: Heap allocation and internal pointers

2014-01-20 Thread Steven Schveighoffer
On Mon, 20 Jan 2014 11:35:10 -0500, Dmitry Olshansky wrote: 19-Jan-2014 20:18, monarch_dodra пишет: My usecase is pretty trivial: A linked list. This is often implemented as a "single" sentinel that serves as both pre-head/post-tail. When the list is empty, the sentinel simply points to i

Re: Heap allocation and internal pointers

2014-01-20 Thread monarch_dodra
On Monday, 20 January 2014 at 19:48:01 UTC, Steven Schveighoffer wrote: On Mon, 20 Jan 2014 11:35:10 -0500, Dmitry Olshansky wrote: 19-Jan-2014 20:18, monarch_dodra пишет: My usecase is pretty trivial: A linked list. This is often implemented as a "single" sentinel that serves as both p

Re: Heap allocation and internal pointers

2014-01-20 Thread Dmitry Olshansky
20-Jan-2014 23:48, Steven Schveighoffer пишет: On Mon, 20 Jan 2014 11:35:10 -0500, Dmitry Olshansky wrote: 19-Jan-2014 20:18, monarch_dodra пишет: My usecase is pretty trivial: A linked list. This is often implemented as a "single" sentinel that serves as both pre-head/post-tail. When the

Re: Heap allocation and internal pointers

2014-01-20 Thread Dmitry Olshansky
20-Jan-2014 23:41, Steven Schveighoffer пишет: On Mon, 20 Jan 2014 14:22:34 -0500, monarch_dodra wrote: On Monday, 20 January 2014 at 12:27:41 UTC, Dicebot wrote: Quick dlang.org investigation has found this: http://dlang.org/phobos/std_exception.html#.pointsTo Note: Evaluating pointsTo(x,

Re: Heap allocation and internal pointers

2014-01-20 Thread Steven Schveighoffer
On Mon, 20 Jan 2014 14:58:12 -0500, Dmitry Olshansky wrote: 20-Jan-2014 23:48, Steven Schveighoffer пишет: I think this is somewhat too general. It can be GC allocated, even GC-array allocated. The GC will not move around your array unexpectedly without updating the pointers. But a movin

Re: Heap allocation and internal pointers

2014-01-24 Thread Tobias Pankrath
On Friday, 24 January 2014 at 12:40:44 UTC, Tobias Pankrath wrote: On Monday, 20 January 2014 at 20:20:01 UTC, Steven Schveighoffer wrote: On Mon, 20 Jan 2014 14:58:12 -0500, Dmitry Olshansky wrote: 20-Jan-2014 23:48, Steven Schveighoffer пишет: I think this is somewhat too general. It can

Re: Heap allocation and internal pointers

2014-01-24 Thread Tobias Pankrath
On Monday, 20 January 2014 at 20:20:01 UTC, Steven Schveighoffer wrote: On Mon, 20 Jan 2014 14:58:12 -0500, Dmitry Olshansky wrote: 20-Jan-2014 23:48, Steven Schveighoffer пишет: I think this is somewhat too general. It can be GC allocated, even GC-array allocated. The GC will not move aro