Re: Virtual methods on stack objects

2022-05-12 Thread vit via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 20:53:21 UTC, Marvin Hannott wrote: On Wednesday, 11 May 2022 at 20:23:07 UTC, Ali Çehreli wrote: On 5/11/22 13:06, Marvin Hannott wrote: > I appreciate the answer, don't much like the "solutions". Me neither. :) > It's not so much about copying Great! > scoped

Re: Virtual methods on stack objects

2022-05-11 Thread dangbinghoo via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 20:53:21 UTC, Marvin Hannott wrote: On Wednesday, 11 May 2022 at 20:23:07 UTC, Ali Çehreli wrote: [...] Yeah, but you can't return `Cat` 😉. And the documentation for `scoped` says: [...] That's kinda very limiting. Anyway, I cooked up another idea based on you

Re: Virtual methods on stack objects

2022-05-11 Thread Marvin Hannott via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 20:23:07 UTC, Ali Çehreli wrote: On 5/11/22 13:06, Marvin Hannott wrote: > I appreciate the answer, don't much like the "solutions". Me neither. :) > It's not so much about copying Great! > scoped class objects should have value semantics. std.typecons.scoped do

Re: Virtual methods on stack objects

2022-05-11 Thread Ali Çehreli via Digitalmars-d-learn
On 5/11/22 13:06, Marvin Hannott wrote: > I appreciate the answer, don't much like the "solutions". Me neither. :) > It's not so much about copying Great! > scoped class objects should have value semantics. std.typecons.scoped does exactly that: https://dlang.org/phobos/std_typecons.html#

Re: Virtual methods on stack objects

2022-05-11 Thread Marvin Hannott via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 14:44:59 UTC, Ali Çehreli wrote: On 5/11/22 06:57, Marvin Hannott wrote: > I understand that D's classes solve some particular problems. However, > they also cause problems because they cannot be copied when scoped. So > how do I get virtual methods on a copyable sta

Re: Virtual methods on stack objects

2022-05-11 Thread Ali Çehreli via Digitalmars-d-learn
On 5/11/22 06:57, Marvin Hannott wrote: > I understand that D's classes solve some particular problems. However, > they also cause problems because they cannot be copied when scoped. So > how do I get virtual methods on a copyable stack object? Problems classes solve don't usually need copying n

Virtual methods on stack objects

2022-05-11 Thread Marvin Hannott via Digitalmars-d-learn
Hi everybody! I understand that D's classes solve some particular problems. However, they also cause problems because they cannot be copied when scoped. So how do I get virtual methods on a copyable stack object?