When is a slice not a slice?
Alix Pexton via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jun 16 02:16:47 PDT 2014
On 06/06/2014 7:39 PM, Steven Schveighoffer wrote:
> On Fri, 06 Jun 2014 06:14:30 -0400, Rene Zwanenburg
> <renezwanenburg at gmail.com> wrote:
>> Immutables should be usable at compile time and not allocate a new
>> instance on every use when in module scope.
>
> I was about to say this. But immutable can have its own set of issues.
> If you want strictly compile-time generation of data, then immutable is
> the way to go.
>
> But if you want to use it at runtime as well, immutable can hamper some
> things. I'm sure your example is a very small or reduced snippet of what
> you are actually doing.
>
> -Steve
Something I read in Adam's D Cookbook (somewhere in chapter 9) got me
thinking that I am on the wrong track with the code I was talking about
here.
My new plan is to make the values that are currently passes to the
structs' constructors into enums, then make the instances of the structs
into static immutables. I'll need some factory methods in my struct but
nothing to taxing.
Thanks again for your advice.
More information about the Digitalmars-d-learn
mailing list