When is a slice not a slice?

2014-06-05 Thread Alix Pexton via Digitalmars-d-learn
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,

Re: When is a slice not a slice?

2014-06-06 Thread Alix Pexton via Digitalmars-d-learn
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

Re: When is a slice not a slice?

2014-06-06 Thread Alix Pexton via Digitalmars-d-learn
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

Re: When is a slice not a slice?

2014-06-06 Thread Alix Pexton via Digitalmars-d-learn
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

Re: When is a slice not a slice?

2014-06-07 Thread Alix Pexton via Digitalmars-d-learn
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.

mangled coverage report

2014-06-07 Thread Alix Pexton via Digitalmars-d-learn
I've just noticed that in the .lst file for one of my libs the execution counts stop lining up with the source, and the source itself is truncated by a couple of lines. The function where the misalignment begins contains an "if (__ctfe)" block (first time I ever used one) but just testing that

Re: When is a slice not a slice?

2014-06-16 Thread Alix Pexton via Digitalmars-d-learn
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

Re: Passing around a list of differently typed functions

2014-06-23 Thread Alix Pexton via Digitalmars-d-learn
On 23/06/2014 8:19 AM, Bienlein wrote: On Monday, 23 June 2014 at 01:16:49 UTC, Evan Davis wrote: As the subject says, I would like to pass around an array of functions. The trick is, that the functions have different type signatures. Is there a way to put the two functions int foo(int a, int b

Re: ddoc and CODE_HIGHLIGHT macro

2014-07-27 Thread Alix Pexton via Digitalmars-d-learn
On 26/07/2014 4:31 PM, Nick Treleaven wrote: Hi, Ddoc doesn't seem to expand a macro near top of http://dlang.org/hash-map.html: // The $(CODE_HIGHLIGHT KeyType) is string Which is weird because it expands it for 'remove' on this line not far below it: b.remove("hello"); Maybe a bug in dmd?