Re: Class qualifier vs struct qualifier

2018-06-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, June 16, 2018 07:13:28 Timoses via Digitalmars-d-learn wrote: > On Thursday, 14 June 2018 at 17:07:09 UTC, Jonathan M Davis wrote: > > Sure, it would save you a little bit of typing when you do > > something like > > > > auto foo = new Foo; > > > > if makes it immutable for you, but

Re: Class qualifier vs struct qualifier

2018-06-16 Thread Timoses via Digitalmars-d-learn
On Thursday, 14 June 2018 at 17:07:09 UTC, Jonathan M Davis wrote: Sure, it would save you a little bit of typing when you do something like auto foo = new Foo; if makes it immutable for you, but it's at the cost of code clarity. Why should it even? Isn't immutable class C {

Re: Class qualifier vs struct qualifier

2018-06-15 Thread David Bennett via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 07:35:25 UTC, RazvanN wrote: Hello, I'm having a hard time understanding whether this inconsistency is a bug or intended behavior: immutable class Foo {} immutable struct Bar {} void main() { import std.stdio : writeln; Foo a; Bar b;

Re: Class qualifier vs struct qualifier

2018-06-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 14, 2018 08:39:48 RazvanN via Digitalmars-d-learn wrote: > > Honestly, from what I understand of how this works, what I find > > weird is the struct case. immutable on classes does _not_ make > > the class itself immutable. It just makes all of its members > > immutable - hence

Re: Class qualifier vs struct qualifier

2018-06-14 Thread RazvanN via Digitalmars-d-learn
Honestly, from what I understand of how this works, what I find weird is the struct case. immutable on classes does _not_ make the class itself immutable. It just makes all of its members immutable - hence the error about trying to allocate new Foo instead of new immutable Foo. So, that is

Re: Class qualifier vs struct qualifier

2018-06-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 13, 2018 14:33:48 Jonathan M Davis via Digitalmars-d- learn wrote: > On Wednesday, June 13, 2018 07:35:25 RazvanN via Digitalmars-d-learn wrote: > > Hello, > > > > I'm having a hard time understanding whether this inconsistency > > is a bug or intended behavior: > > > >

Re: Class qualifier vs struct qualifier

2018-06-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 13, 2018 07:35:25 RazvanN via Digitalmars-d-learn wrote: > Hello, > > I'm having a hard time understanding whether this inconsistency > is a bug or intended behavior: > > immutable class Foo {} > immutable struct Bar {} > > void main() > { > import std.stdio : writeln; >

Re: Class qualifier vs struct qualifier

2018-06-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/13/18 3:35 AM, RazvanN wrote: Hello, I'm having a hard time understanding whether this inconsistency is a bug or intended behavior: immutable class Foo {} immutable struct Bar {} void main() {     import std.stdio : writeln;     Foo a;     Bar b;     writeln("typeof(a): ",

Class qualifier vs struct qualifier

2018-06-13 Thread RazvanN via Digitalmars-d-learn
Hello, I'm having a hard time understanding whether this inconsistency is a bug or intended behavior: immutable class Foo {} immutable struct Bar {} void main() { import std.stdio : writeln; Foo a; Bar b; writeln("typeof(a): ", typeof(a).stringof); writeln("typeof(b): ",