Re: linking trouble

2018-09-06 Thread Mike Parker via Digitalmars-d-learn
On Friday, 7 September 2018 at 02:44:24 UTC, hridyansh thakur wrote: On Thursday, 6 September 2018 at 16:59:43 UTC, rikki cattermole wrote: On 07/09/2018 4:03 AM, hridyansh thakur wrote: [...] That definition isn't complete. Missing at the very least ``();`` to make it a function

Re: Alias this and opDispatch override

2018-09-06 Thread Domain via Digitalmars-d-learn
On Friday, 7 September 2018 at 02:22:58 UTC, Domain wrote: The following code fail to compile: enum KeyMod : int { LCtrl = 1 << 0, RCtrl = 1 << 1, Ctrl = LCtrl | RCtrl, } struct Flags(E) { public: BitFlags!(E, Yes.unsafe) flags; alias flags this; bool

Re: linking trouble

2018-09-06 Thread hridyansh thakur via Digitalmars-d-learn
On Thursday, 6 September 2018 at 16:59:43 UTC, rikki cattermole wrote: On 07/09/2018 4:03 AM, hridyansh thakur wrote: [...] That definition isn't complete. Missing at the very least ``();`` to make it a function declaration. [...] So what is the errors you're getting? And what are the

Alias this and opDispatch override

2018-09-06 Thread Domain via Digitalmars-d-learn
The following code fail to compile: enum KeyMod : int { LCtrl = 1 << 0, RCtrl = 1 << 1, Ctrl = LCtrl | RCtrl, } struct Flags(E) { public: BitFlags!(E, Yes.unsafe) flags; alias flags this; bool opDispatch(string name)() const if (__traits(hasMember, E, name))

Re: Bug with writeln?

2018-09-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 6, 2018 1:05:03 PM MDT Steven Schveighoffer via Digitalmars-d-learn wrote: > On 9/6/18 2:52 PM, Jonathan M Davis wrote: > > On Thursday, September 6, 2018 12:21:24 PM MDT Steven Schveighoffer via > > > > Digitalmars-d-learn wrote: > >> On 9/6/18 12:55 PM, Jonathan M Davis

Re: Bug with writeln?

2018-09-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/6/18 2:52 PM, Jonathan M Davis wrote: On Thursday, September 6, 2018 12:21:24 PM MDT Steven Schveighoffer via Digitalmars-d-learn wrote: On 9/6/18 12:55 PM, Jonathan M Davis wrote: It's not a bug in writeln. Any time that a range is copied, you must not do _anything_ else with the

Re: Bug with writeln?

2018-09-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 6, 2018 12:21:24 PM MDT Steven Schveighoffer via Digitalmars-d-learn wrote: > On 9/6/18 12:55 PM, Jonathan M Davis wrote: > > On Thursday, September 6, 2018 2:40:08 AM MDT Saurabh Das via > > Digitalmars-d-> > > learn wrote: > >> Is this a bug with writeln? > >> > >> void

Re: file io

2018-09-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/6/18 2:30 PM, Steven Schveighoffer wrote: On 9/6/18 1:07 PM, rikki cattermole wrote: On 07/09/2018 4:17 AM, Arun Chandrasekaran wrote: On Thursday, 6 September 2018 at 16:13:42 UTC, hridyansh thakur wrote: how to read a file line by line in D std.stdio.File.byLine() Refer the doc

Re: file io

2018-09-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/6/18 1:07 PM, rikki cattermole wrote: On 07/09/2018 4:17 AM, Arun Chandrasekaran wrote: On Thursday, 6 September 2018 at 16:13:42 UTC, hridyansh thakur wrote: how to read a file line by line in D std.stdio.File.byLine() Refer the doc here:

Re: Bug with writeln?

2018-09-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/6/18 12:55 PM, Jonathan M Davis wrote: On Thursday, September 6, 2018 2:40:08 AM MDT Saurabh Das via Digitalmars-d- learn wrote: Is this a bug with writeln? void main() { import std.stdio, std.range, std.algorithm; auto a1 = sort([1,3,5,4,2]); auto a2 = sort([9,8,9]);

Re: Slicing betterC

2018-09-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 6, 2018 11:34:18 AM MDT Adam D. Ruppe via Digitalmars-d-learn wrote: > On Thursday, 6 September 2018 at 17:10:49 UTC, Oleksii wrote: > > struct Slice(T) { > > > > size_t capacity; > > size_t size; > > T* memory; > > > > } > > There's no capacity in the slice, that

Re: Slicing betterC

2018-09-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 6 September 2018 at 17:10:49 UTC, Oleksii wrote: struct Slice(T) { size_t capacity; size_t size; T* memory; } There's no capacity in the slice, that is stored as part of the GC block, which it looks up with the help of RTTI, thus the TypeInfo reference. Slices *just*

Re: Slicing betterC

2018-09-06 Thread Oleksii via Digitalmars-d-learn
On Thursday, 6 September 2018 at 17:10:49 UTC, Oleksii wrote: allocatedFoo = foos[0 .. $ + 1];// <= Error: TypeInfo This line meant to be `allocatedFoo = foos[$]`. Sorry about that.

Slicing betterC

2018-09-06 Thread Oleksii via Digitalmars-d-learn
Hi the folks, Could you please share your wisdom with me? I wonder why the following code: ``` import core.stdc.stdlib; Foo[] pool; Foo[] foos; auto buff = (Foo*)malloc(Foo.sizeof * 10); pool = buff[0 .. 10]; foos = pool[0 .. 0 ]; // Now let's allocate a Foo: Foo* allocatedFoo; if

Re: file io

2018-09-06 Thread rikki cattermole via Digitalmars-d-learn
On 07/09/2018 4:17 AM, Arun Chandrasekaran wrote: On Thursday, 6 September 2018 at 16:13:42 UTC, hridyansh thakur wrote: how to read a file line by line in D std.stdio.File.byLine() Refer the doc here: https://dlang.org/library/std/stdio/file.by_line.html An example from the doc: ```

Re: linking trouble

2018-09-06 Thread rikki cattermole via Digitalmars-d-learn
On 07/09/2018 4:03 AM, hridyansh thakur wrote: i am on windows i have tried DMD LDC and i am getting same linking error with linking my c++ object i am doing by the official tutorial (dlang spec book) here is my app.d code import std.stdio; void main() { //writeln("Edit source/app.d to

Re: Bug with writeln?

2018-09-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 6, 2018 2:40:08 AM MDT Saurabh Das via Digitalmars-d- learn wrote: > Is this a bug with writeln? > > void main() > { > import std.stdio, std.range, std.algorithm; > > auto a1 = sort([1,3,5,4,2]); > auto a2 = sort([9,8,9]); > auto a3 = sort([5,4,5,4]); > >

Re: Example of using C API from D?

2018-09-06 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2018-09-03 at 11:41 +1200, rikki cattermole via Digitalmars-d-learn wrote: […] > > You won't need to actually fill out any c struct's that you don't need > either. Make them opaque as long as they are referenced via pointer and > not by value. True. And indeed Fontconfig can mostly

Re: file io

2018-09-06 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Thursday, 6 September 2018 at 16:13:42 UTC, hridyansh thakur wrote: how to read a file line by line in D std.stdio.File.byLine() Refer the doc here: https://dlang.org/library/std/stdio/file.by_line.html An example from the doc: ``` import std.algorithm, std.stdio, std.string; // Count

file io

2018-09-06 Thread hridyansh thakur via Digitalmars-d-learn
how to read a file line by line in D

linking trouble

2018-09-06 Thread hridyansh thakur via Digitalmars-d-learn
i am on windows i have tried DMD LDC and i am getting same linking error with linking my c++ object i am doing by the official tutorial (dlang spec book) here is my app.d code import std.stdio; void main() { //writeln("Edit source/app.d to start your project."); int[] m =

Re: hasAliasing with nested static array bug ?

2018-09-06 Thread SrMordred via Digitalmars-d-learn
On Thursday, 6 September 2018 at 07:37:11 UTC, Simen Kjærås wrote: On Wednesday, 5 September 2018 at 22:35:16 UTC, SrMordred wrote: https://run.dlang.io/is/TOTsL4 Yup, that's a bug. Reduced example: struct S { int*[1] arr; } import std.traits : hasAliasing; static assert(hasAliasing!S);

Re: Meson issue with -L--export-dynamic flag

2018-09-06 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2018-09-03 at 13:19 +, Gerald via Digitalmars-d-learn wrote: > Myself and some others are looking at replacing autotools in > Tilix with meson for the various Linux distros to use when > building and packaging the binary. However we are running into an > issue with meson around the

Re: C++ GLM(OpenGL Mathematics) D Equivalent.

2018-09-06 Thread Guillaume Piolat via Digitalmars-d-learn
On Tuesday, 4 September 2018 at 19:23:16 UTC, SrMordred wrote: Most C++ game related projects uses GLM as they default math/vector lib (even if not using opengl). In D we have (that I found): gfm.math - https://github.com/d-gamedev-team/gfm dlib.math - https://github.com/gecko0307/dlib Gl3n

Re: Bug with writeln?

2018-09-06 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 6 September 2018 at 09:06:21 UTC, Simen Kjærås wrote: On Thursday, 6 September 2018 at 08:40:08 UTC, Saurabh Das wrote: Is this a bug with writeln? Yup. What happens is writeln destructively iterates over b[i]. Since b[i] is a forward range, this shouldn't be done

Re: Bug with writeln?

2018-09-06 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 6 September 2018 at 08:40:08 UTC, Saurabh Das wrote: Is this a bug with writeln? Yup. What happens is writeln destructively iterates over b[i]. Since b[i] is a forward range, this shouldn't be done destructively. Instead, a copy should be made using b[i].save, somewhere deep in

Bug with writeln?

2018-09-06 Thread Saurabh Das via Digitalmars-d-learn
Is this a bug with writeln? void main() { import std.stdio, std.range, std.algorithm; auto a1 = sort([1,3,5,4,2]); auto a2 = sort([9,8,9]); auto a3 = sort([5,4,5,4]); pragma(msg, typeof(a1)); pragma(msg, typeof(a2)); pragma(msg, typeof(a3)); auto b = [a1, a2,

Re: How to understand context type of a delegate?

2018-09-06 Thread Kagamin via Digitalmars-d-learn
Maybe poke into GC and see if it has ClassInfo associated with the allocated block.

Re: hasAliasing with nested static array bug ?

2018-09-06 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 5 September 2018 at 22:35:16 UTC, SrMordred wrote: https://run.dlang.io/is/TOTsL4 Yup, that's a bug. Reduced example: struct S { int*[1] arr; } import std.traits : hasAliasing; static assert(hasAliasing!S); Issue filed: https://issues.dlang.org/show_bug.cgi?id=19228 Pull