Re: Are stack+heap classes possible in D?

2015-06-19 Thread rsw0x via Digitalmars-d-learn
On Friday, 19 June 2015 at 19:10:11 UTC, Shachar Shemesh wrote: On 14/06/15 04:31, Adam D. Ruppe wrote: On Sunday, 14 June 2015 at 00:52:20 UTC, FujiBar wrote: I have read that in D structs are always allocated on the stack while classes are always allocated on the heap. That's not true; it

Re: Are stack+heap classes possible in D?

2015-06-19 Thread Shachar Shemesh via Digitalmars-d-learn
On 14/06/15 04:31, Adam D. Ruppe wrote: On Sunday, 14 June 2015 at 00:52:20 UTC, FujiBar wrote: I have read that in D structs are always allocated on the stack while classes are always allocated on the heap. That's not true; it is a really common misconception. Putting a struct on the heap

Re: Are stack+heap classes possible in D?

2015-06-17 Thread ketmar via Digitalmars-d-learn
On Wed, 17 Jun 2015 06:02:46 +, WhatMeWorry wrote: I guess the question would be why would one want a struct on the heap and a class on the stack? Performance reasons? struct on the heap: some containers, for example, doing their own memory management. class on the stack: guaranteed

Re: Are stack+heap classes possible in D?

2015-06-17 Thread WhatMeWorry via Digitalmars-d-learn
On Sunday, 14 June 2015 at 01:31:25 UTC, Adam D. Ruppe wrote: On Sunday, 14 June 2015 at 00:52:20 UTC, FujiBar wrote: I have read that in D structs are always allocated on the stack while classes are always allocated on the heap. That's not true; it is a really common misconception. Putting

Are stack+heap classes possible in D?

2015-06-13 Thread FujiBar via Digitalmars-d-learn
I have read that in D structs are always allocated on the stack while classes are always allocated on the heap. Well, I often have classes where I want some instances on the stack, some on the heap. So.. what to do?

Re: Are stack+heap classes possible in D?

2015-06-13 Thread FujiBar via Digitalmars-d-learn
On Sunday, 14 June 2015 at 01:31:25 UTC, Adam D. Ruppe wrote: On Sunday, 14 June 2015 at 00:52:20 UTC, FujiBar wrote: I have read that in D structs are always allocated on the stack while classes are always allocated on the heap. That's not true; it is a really common misconception. Putting

Re: Are stack+heap classes possible in D?

2015-06-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 June 2015 at 00:52:20 UTC, FujiBar wrote: I have read that in D structs are always allocated on the stack while classes are always allocated on the heap. That's not true; it is a really common misconception. Putting a struct on the heap is trivial and built into the language: