Why D doesn't have an equivalent to C#'s readonly?

2015-06-30 Thread Assembly via Digitalmars-d-learn
I believe it's a design choice, if so, could someone explain why? is immutable better than C#'s readonly so that the readonly keyword isn't even needed? for example, I'd like to declare a member as readonly but I can't do it directly because immutable create a new type (since it's a type

Re: Why D doesn't have an equivalent to C#'s readonly?

2015-06-30 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 29 June 2015 at 20:12:12 UTC, Assembly wrote: I believe it's a design choice, if so, could someone explain why? is immutable better than C#'s readonly so that the readonly keyword isn't even needed? for example, I'd like to declare a member as readonly but I can't do it directly

Re: Why D doesn't have an equivalent to C#'s readonly?

2015-06-30 Thread anonymous via Digitalmars-d-learn
On Monday, 29 June 2015 at 22:11:16 UTC, sigod wrote: `new immutable(MyClass)()` is invalid code. It's perfectly fine, actually.

Re: Why D doesn't have an equivalent to C#'s readonly?

2015-06-30 Thread sigod via Digitalmars-d-learn
On Monday, 29 June 2015 at 20:12:12 UTC, Assembly wrote: I believe it's a design choice, if so, could someone explain why? is immutable better than C#'s readonly so that the readonly keyword isn't even needed? for example, I'd like to declare a member as readonly but I can't do it directly

Re: Why D doesn't have an equivalent to C#'s readonly?

2015-06-30 Thread sigod via Digitalmars-d-learn
On Monday, 29 June 2015 at 22:22:46 UTC, anonymous wrote: On Monday, 29 June 2015 at 22:11:16 UTC, sigod wrote: `new immutable(MyClass)()` is invalid code. It's perfectly fine, actually. Yes, you're right. It seems I've mistyped `immutable` when was checking it with compiler.