On Thursday, 5 June 2014 at 19:45:59 UTC, Alix Pexton wrote:
unittest
{
auto a = DataAndView(1);
assert (sameTail(a.data, a.view));
enum b = DataAndView(1);
assert (!sameTail(b.data, b.view));
}
Just a request of presentation. Please make expected assertions:
On 06/06/2014 7:39 PM, Steven Schveighoffer wrote:
On Fri, 06 Jun 2014 06:14:30 -0400, Rene Zwanenburg
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.
I
On 06/06/2014 7:39 PM, Steven Schveighoffer wrote:
On Fri, 06 Jun 2014 06:14:30 -0400, Rene Zwanenburg
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.
On Fri, 06 Jun 2014 06:14:30 -0400, Rene Zwanenburg
wrote:
On Friday, 6 June 2014 at 08:17:43 UTC, Alix Pexton wrote:
On 05/06/2014 8:58 PM, Steven Schveighoffer wrote:
Yes, this should work (and execute the initializer at compile time):
static b = ...
Ah, the problem with static is t
On Friday, 6 June 2014 at 08:17:43 UTC, Alix Pexton wrote:
On 05/06/2014 8:58 PM, Steven Schveighoffer wrote:
On Thu, 05 Jun 2014 15:56:00 -0400, Philippe Sigaud via
Digitalmars-d-learn wrote:
enum b = DataAndView(1);
assert (!sameTail(b.data, b.view));
I suppose it's because
On 05/06/2014 8:58 PM, Steven Schveighoffer wrote:
On Thu, 05 Jun 2014 15:56:00 -0400, Philippe Sigaud via
Digitalmars-d-learn wrote:
enum b = DataAndView(1);
assert (!sameTail(b.data, b.view));
I suppose it's because enums are manifest constants: the value they
represent is
On 06/06/2014 8:52 AM, Alix Pexton wrote:
And the two DataAndView(1), being completely separated, do not have
the same tail.
Ah, Isee, that does kinda make sense ^^ A re-factoring we go...
However, the code that originally tripped over this issue had the call
to sameTail in the struct's
On 05/06/2014 8:56 PM, Philippe Sigaud via Digitalmars-d-learn wrote:
enum b = DataAndView(1);
assert (!sameTail(b.data, b.view));
I suppose it's because enums are manifest constants: the value they
represent is 'copy-pasted' anew everywhere it appears in the code. So
for arra
On Thu, 05 Jun 2014 15:56:00 -0400, Philippe Sigaud via
Digitalmars-d-learn wrote:
enum b = DataAndView(1);
assert (!sameTail(b.data, b.view));
I suppose it's because enums are manifest constants: the value they
represent is 'copy-pasted' anew everywhere it appears in the co
> enum b = DataAndView(1);
> assert (!sameTail(b.data, b.view));
I suppose it's because enums are manifest constants: the value they
represent is 'copy-pasted' anew everywhere it appears in the code. So
for arrays and associative arrays, it means recreating a new value
each and eve
In CTFE it seems. Only tested with DMD on Windows though. Is this a
known limitation, or a bug, I couldn't find anything that seemed to
match it in the bugzilla.
import std.array;
struct DataAndView
{
int[] data, view;
this(int x)
{
data = [1, 2, 3, 4,
11 matches
Mail list logo