Thank you both.
On 08/12/2016 01:35 AM, Jonathan M Davis via Digitalmars-d-learn wrote:
On Friday, August 12, 2016 05:25:45 Mike Parker via Digitalmars-d-learn wrote:
immutable class Foo { ... } is the same as declaring every member
of Foo as immutable, just as final class Foo { ... } makes
On Friday, 12 August 2016 at 08:35:54 UTC, Jonathan M Davis wrote:
On Friday, August 12, 2016 05:25:45 Mike Parker via
Digitalmars-d-learn wrote:
immutable class Foo { ... } is the same as declaring every
member of Foo as immutable, just as final class Foo { ... }
makes every method final.
On Thursday, August 11, 2016 21:49:46 Charles Hixson via Digitalmars-d-learn
wrote:
> It works, it's just not the syntax that I'd prefer. And it leaves me
> wondering exactly what
> immutable class Msg {...}
> was declaring.
All it does is make the members of the class immutable. It doesn't
On Friday, August 12, 2016 05:25:45 Mike Parker via Digitalmars-d-learn wrote:
> immutable class Foo { ... } is the same as declaring every member
> of Foo as immutable, just as final class Foo { ... } makes every
> method final.
I'm not sure that that's quite the same thing, because there is
On Friday, 12 August 2016 at 04:49:46 UTC, Charles Hixson wrote:
It works, it's just not the syntax that I'd prefer. And it
leaves me wondering exactly what
immutable class Msg {...}
was declaring.
This should demonstrate:
```
immutable class iMsg {
int getX() { return 10; }
}
class
On 08/11/2016 06:33 PM, Mike Parker via Digitalmars-d-learn wrote:
On Friday, 12 August 2016 at 00:44:31 UTC, Charles Hixson wrote:
A way around this, which may be the same as the approach used by
string was:
alias immutable(Msg_)Msg;
classMsg_
{ ...
This is exactly what Jonathan
On Friday, 12 August 2016 at 00:44:31 UTC, Charles Hixson wrote:
A way around this, which may be the same as the approach used
by string was:
alias immutable(Msg_)Msg;
classMsg_
{ ...
This is exactly what Jonathan suggested in the post above. And
yes, it's how string is handled:
A way around this, which may be the same as the approach used by string was:
alias immutable(Msg_)Msg;
classMsg_
{ ...
This so far appears to do what I want. The only problem is that it
introduces an extraneous symbol, which I would prefer to avoid.
OTOH, I did fix a few problems
On Thursday, August 11, 2016 10:56:59 Charles Hixson via Digitalmars-d-learn
wrote:
> I want to declare a class all instances of which will be immutable, and
> all references to which will be inherently immutable (so that I don't
> need to slip a huge number of "immutable" statements in my code).
On Thursday, 11 August 2016 at 17:56:59 UTC, Charles Hixson wrote:
Does anyone know the correct approach?
I do:
°°
immutable class Foo
{
this() {}
}
void main()
{
auto foo = new immutable(Foo);
}
°°
But take care because you
I want to declare a class all instances of which will be immutable, and
all references to which will be inherently immutable (so that I don't
need to slip a huge number of "immutable" statements in my code).
This is surely possible, because string acts just that way, but I can't
figure out
11 matches
Mail list logo