Re: Should I prefer immutable or const?

2016-11-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 02, 2016 23:23:22 Nordlöw via Digitalmars-d-learn wrote: > On Tuesday, 1 November 2016 at 18:55:26 UTC, Jonathan M Davis > > wrote: > > - Jonathan M Davis > > Thanks. I'll go for immutable, when possible, then. > > I wish I had a shorter way to write immutable, though :) > >

Re: Should I prefer immutable or const?

2016-11-02 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 1 November 2016 at 18:55:26 UTC, Jonathan M Davis wrote: - Jonathan M Davis Thanks. I'll go for immutable, when possible, then. I wish I had a shorter way to write immutable, though :) Do you think it would be possible to adopt Rust's syntax `let`?

Re: Should I prefer immutable or const?

2016-11-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 01, 2016 17:52:56 Nordlöw via Digitalmars-d-learn wrote: > Should I always, when possible, prefer `immutable` over `const`? > > And does `immutable` increase the possibility of the compiler > doing optimizations, such as common subexpression elimination? > > Or can the compile

Re: Should I prefer immutable or const?

2016-11-01 Thread ag0aep6g via Digitalmars-d-learn
On 11/01/2016 06:52 PM, Nordlöw wrote: Should I always, when possible, prefer `immutable` over `const`? I'd say: prefer immutable. And does `immutable` increase the possibility of the compiler doing optimizations, such as common subexpression elimination? Or can the compiler infer `const` de

Should I prefer immutable or const?

2016-11-01 Thread Nordlöw via Digitalmars-d-learn
Should I always, when possible, prefer `immutable` over `const`? And does `immutable` increase the possibility of the compiler doing optimizations, such as common subexpression elimination? Or can the compiler infer `const` declarations to also be `immutable`?