Re: DMD Callstacks

2017-10-23 Thread abad via Digitalmars-d-learn
On Monday, 23 October 2017 at 12:41:09 UTC, Márcio Martins wrote: What is everyone doing to get proper file name and line number info for callstacks with DMD? addr2line just gives me ??:0 You could try compiling with the -debug-switch. Of course if this turns out to be the fix, it doesn't he

Operator overloading - operations on slices

2016-01-21 Thread abad via Digitalmars-d-learn
I am trying to create a generic interface to arrays. Most operations except those on elements of slices. Code: class Table(T) { T[] data; this(T[] data) { this.data = data; } auto ref opSlice(size_t x, size_t y) { return new Tabl

Re: Operator overloading - operations on slices

2016-01-21 Thread abad via Digitalmars-d-learn
On Thursday, 21 January 2016 at 11:15:22 UTC, abad wrote: I am trying to create a generic interface to arrays. Most operations except those on elements of slices. Code: class Table(T) { T[] data; this(T[] data) { this.data = data; } auto ref op

Collapsing n-dimensional array to linear (1 dimensional)

2016-01-22 Thread abad via Digitalmars-d-learn
Let's say I have an array like this: int[][][] array; And I want to generate a linear int[] based on its data. Is there a standard library method for achieving this, or must I iterate over the array manually? What I'm thinking of is something like this: int[] onedim = std.array.collapse(arr

Re: Collapsing n-dimensional array to linear (1 dimensional)

2016-01-25 Thread abad via Digitalmars-d-learn
On Monday, 25 January 2016 at 02:27:57 UTC, Solomon E wrote: On Saturday, 23 January 2016 at 07:57:55 UTC, Ali Çehreli wrote: auto collapse(R)(R r) if (isArray!R) { return r.joiner.collapse.joiner; } auto collapse(R)(R r) if (!isArray!R) { return r; } Ali, that code

DUB and static libs

2016-04-20 Thread abad via Digitalmars-d-learn
I have a project which is a mixture of D, C++ and C. I have used Make for build automation so far but would like to migrate to DUB. I have hard time figuring out what to do with C / C++ sections of the program. DUB seems to ignore (probably sensibly) everything but D source files. I compiled a

Calling C++ code with pointer** argument

2016-06-01 Thread abad via Digitalmars-d-learn
D source: extern(C++) void thisWorks(const char* test); extern(C++) void doesNotLink(const char** test); void main() { char* baz1; char** baz2; thisWorks(baz1); doesNotLink(baz2); } CPP source: #include void thisWorks(const char* test) { printf("hi\n"); } void DoesNotLin

Re: Calling C++ code with pointer** argument

2016-06-01 Thread abad via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 07:17:04 UTC, Mike Parker wrote: On Wednesday, 1 June 2016 at 07:09:16 UTC, abad wrote: Try this: extern(C++) void DoesNotLink(const(char)**); That does work, though I have to explicitly cast it in my caller as well. Like this: doesNotLink(cast(const(char)**)ba

std.array : appender woes

2016-06-16 Thread abad via Digitalmars-d-learn
import std.array : appender; import std.stdio : writeln; void main() { auto app = appender!(char[]); app.put('x'); auto foo = app.data; app.clear; // done, start a new array app.put('y'); writeln(foo); } This prints out 'y'. It's not surprising because what I suppose app

Re: std.array : appender woes

2016-06-16 Thread abad via Digitalmars-d-learn
On Thursday, 16 June 2016 at 07:59:50 UTC, cym13 wrote: On Thursday, 16 June 2016 at 07:47:03 UTC, abad wrote: import std.array : appender; import std.stdio : writeln; void main() { auto app = appender!(char[]); app.put('x'); auto foo = app.data; app.clear; // done, start a new

Re: understanding std.algorithm.mutation.fill behaivor.

2016-12-28 Thread abad via Digitalmars-d-learn
On Wednesday, 28 December 2016 at 08:10:41 UTC, Nemanja Boric wrote: On Wednesday, 28 December 2016 at 05:09:34 UTC, LeqxLeqx wrote: Perhaps this is a stupid question, and I apologize if it is, but why doesn't this compile: import std.algorithm; import std.stdio; void main() {

Why is this legal?

2017-03-29 Thread abad via Digitalmars-d-learn
This works: class Foo { protected void bar() { writeln("hello from foo"); } } void main() { auto foo = new Foo; foo.bar(); } Is this on purpose and what's the rationale?

Re: Why is this legal?

2017-03-29 Thread abad via Digitalmars-d-learn
Never mind, it's working OK if the class is defined in another module.

Re: Why is this legal?

2017-03-29 Thread abad via Digitalmars-d-learn
Related question, it seems that final methods are allowed in interfaces. Obviously you can't implement them anywhere, so is this also on purpose and on what rationale? :)

Re: Why is this legal?

2017-03-29 Thread abad via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 10:08:02 UTC, abad wrote: Related question, it seems that final methods are allowed in interfaces. Obviously you can't implement them anywhere, so is this also on purpose and on what rationale? :) So actually it's just a question of not catching this mistake ear

Re: Why is this legal?

2017-03-29 Thread abad via Digitalmars-d-learn
On Wednesday, 29 March 2017 at 11:06:55 UTC, Petar Kirov [ZombineDev] wrote: On Wednesday, 29 March 2017 at 10:12:08 UTC, abad wrote: On Wednesday, 29 March 2017 at 10:08:02 UTC, abad wrote: Related question, it seems that final methods are allowed in interfaces. Obviously you can't implement t