Linking C++ standard library works with GDC... but not DMD. (Linux)
Hi, I've got this project that requires me to link into a C++ backend. It works just fine when using GDC: gdc *.d [client libraries] However, this command using DMD does not work: dmd -L-lstdc++ *.d [client libraries] I still get errors involving the standard library not being added like: /usr/include/c++/4.8/iostream:74: undefine reference to `std::ios_base::Init::Init()' (etc.) What do I need to do to make this work? Thanks.
Re: Linking C++ standard library works with GDC... but not DMD. (Linux)
On Thursday, 16 April 2015 at 08:51:15 UTC, TheGag96 wrote: Hi, I've got this project that requires me to link into a C++ backend. It works just fine when using GDC: gdc *.d [client libraries] However, this command using DMD does not work: dmd -L-lstdc++ *.d [client libraries] I still get errors involving the standard library not being added like: /usr/include/c++/4.8/iostream:74: undefine reference to `std::ios_base::Init::Init()' (etc.) What do I need to do to make this work? Thanks. Can't get to linux machine now, but you can try place -L-lstdc++ after source files.
Re: Linking C++ standard library works with GDC... but not DMD. (Linux)
On Thursday, 16 April 2015 at 08:51:15 UTC, TheGag96 wrote: Hi, I've got this project that requires me to link into a C++ backend. It works just fine when using GDC: gdc *.d [client libraries] However, this command using DMD does not work: dmd -L-lstdc++ *.d [client libraries] I still get errors involving the standard library not being added like: /usr/include/c++/4.8/iostream:74: undefine reference to `std::ios_base::Init::Init()' (etc.) What do I need to do to make this work? Thanks. I don't know why that's happening, but you can explicitly link using gcc (or ld/gold directly) if you need to. E.g. dmd -c myFile.d gcc myFile.o -lphobos2 or whatever is necessary on your project/system.
Re: Linking C++ standard library works with GDC... but not DMD. (Linux)
On Thursday, 16 April 2015 at 08:51:15 UTC, TheGag96 wrote: Hi, I've got this project that requires me to link into a C++ backend. It works just fine when using GDC: gdc *.d [client libraries] However, this command using DMD does not work: dmd -L-lstdc++ *.d [client libraries] I still get errors involving the standard library not being added like: /usr/include/c++/4.8/iostream:74: undefine reference to `std::ios_base::Init::Init()' (etc.) What do I need to do to make this work? Thanks. Simple issue but unpleasant fix. You always must use C++ library that matches base C++ compiler. For GDC it is GCC (which is used by default). For DMD it is DMC (Digital Mars C compiler). For LDC it is whatever Clang standard library is called. All those are incompatible because rely on different compiler built-ins.
Re: CT-String as a Symbol
On Wednesday, 15 April 2015 at 23:02:32 UTC, Ali Çehreli wrote: struct I { alias T = size_t; this(T ix) { this._ix = ix; } T opCast(U : T)() const { return _ix; } private T _ix = 0; } How is this possible? Shouldn't it CT-evaluate to struct Index { ... } !?
Re: CT-String as a Symbol
On Wednesday, 15 April 2015 at 16:21:59 UTC, Nordlöw wrote: Help please. I'm quite satisfied with the current state now. Is anybody interested in having this in typecons.d in Phobos?
Re: CT-String as a Symbol
On Thursday, 16 April 2015 at 10:24:05 UTC, Per Nordlöw wrote: How is this possible? Shouldn't it CT-evaluate to struct Index { ... } !? Ahh, in the case when I is "I". Ok I get it. That's the reason. Thx
Re: CT-String as a Symbol
On Thursday, 16 April 2015 at 10:27:20 UTC, Per Nordlöw wrote: On Wednesday, 15 April 2015 at 16:21:59 UTC, Nordlöw wrote: Help please. I'm quite satisfied with the current state now. Is anybody interested in having this in typecons.d in Phobos? I would be, yes. Have you considered what happens if you apply it to a type that uses the new opIndex/opSlice semantics?
What is the memory usage of my app?
I've written a simple socket-server app that securities (stock market shares) data and allows clients to query over them. The app starts by loading instrument information from a CSV file into some structs, then listens on a socket responding to queries. It doesn't mutate the data or allocate anything substantial. There are 2 main structs in the app. One stores security data, and the other groups together securities. They are defined as follows : __gshared Securities securities; struct Security { string RIC; string TRBC; string[string] fields; double[string] doubles; @nogc @property pure size_t bytes() { size_t bytes; bytes = RIC.sizeof + RIC.length; bytes += TRBC.sizeof + TRBC.length; foreach(k,v; fields) { bytes += (k.sizeof + k.length + v.sizeof + v.length); } foreach(k, v; doubles) { bytes += (k.sizeof + k.length + v.sizeof); } return bytes + Security.sizeof; } } struct Securities { Security[] securities; private size_t[string] rics; // Store offsets for each TRBC group ulong[2][string] econSect; ulong[2][string] busSect; ulong[2][string] IndGrp; ulong[2][string] Ind; @nogc @property pure size_t bytes() { size_t bytes; foreach(Security s; securities) { bytes += s.sizeof + s.bytes; } foreach(k, v; rics) { bytes += k.sizeof + k.length + v.sizeof; } foreach(k, v; econSect) { bytes += k.sizeof + k.length + v.sizeof; } foreach(k, v; busSect) { bytes += k.sizeof + k.length + v.sizeof; } foreach(k, v; IndGrp) { bytes += k.sizeof + k.length + v.sizeof; } foreach(k, v; Ind) { bytes += k.sizeof + k.length + v.sizeof; } return bytes + Securities.sizeof; } } Calling Securities.bytes shows "188 MB", but "ps" shows about 591 MB of Resident memory. Where is the memory usage coming from? What am i missing?
Re: Linking C++ standard library works with GDC... but not DMD. (Linux)
On 2015-04-16 11:56, Dicebot wrote: Simple issue but unpleasant fix. You always must use C++ library that matches base C++ compiler. For GDC it is GCC (which is used by default). For DMD it is DMC (Digital Mars C compiler). For LDC it is whatever Clang standard library is called. All those are incompatible because rely on different compiler built-ins. The title says (Linux), where DMD uses GCC and not DMC. -- /Jacob Carlborg
Re: Linking C++ standard library works with GDC... but not DMD. (Linux)
On 4/16/15 4:51 AM, TheGag96 wrote: Hi, I've got this project that requires me to link into a C++ backend. It works just fine when using GDC: gdc *.d [client libraries] However, this command using DMD does not work: dmd -L-lstdc++ *.d [client libraries] I still get errors involving the standard library not being added like: /usr/include/c++/4.8/iostream:74: undefine reference to `std::ios_base::Init::Init()' (etc.) Try dmd -v to tell you exactly what command it is running for link. Then play around with the link line to see if you can figure out a way to link it correctly. We can work on fixing the situation from there. Maybe there's a way to link using dmd, maybe we have to fix dmd so it allows the correct link call. -Steve
Re: CURL to get/set cookies
Vladimir & Adam Thank you! This was my last roadblock I needed to overcome to finish my prototype project for the company I work for. After a successful presentation and demo - the company I work for is taking a serious look into the D language for future projects. Thanks! Ben. On Monday, 6 April 2015 at 04:36:36 UTC, Vladimir Panteleev wrote: On Sunday, 5 April 2015 at 23:55:15 UTC, Benjamin wrote: I"m still not able to set the cookie. Would it be possible to provide a few sample lines - to ensure I'm on the right path. I appreciate any additional help!! Thanks! Benjamin This should work: auto cookiesFile = "cookies.txt"; auto http = HTTP(); http.handle.set(CurlOption.cookiefile, cookiesFile); http.handle.set(CurlOption.cookiejar , cookiesFile); get("www.example.com/login.php?username=benjamin&password=hunter2", http); get("www.example.com/action.php?...", http);
Re: Linking C++ standard library works with GDC... but not DMD. (Linux)
On Thursday, 16 April 2015 at 09:46:40 UTC, John Colvin wrote: On Thursday, 16 April 2015 at 08:51:15 UTC, TheGag96 wrote: Hi, I've got this project that requires me to link into a C++ backend. It works just fine when using GDC: gdc *.d [client libraries] However, this command using DMD does not work: dmd -L-lstdc++ *.d [client libraries] I still get errors involving the standard library not being added like: /usr/include/c++/4.8/iostream:74: undefine reference to `std::ios_base::Init::Init()' (etc.) What do I need to do to make this work? Thanks. I don't know why that's happening, but you can explicitly link using gcc (or ld/gold directly) if you need to. E.g. dmd -c myFile.d gcc myFile.o -lphobos2 or whatever is necessary on your project/system. I had wanted to try this too, but I wasn't sure if the linker knew where phobos2 was on my system. I just tried this now for funsies: dmd -c *.d g++ main.o [client files] -lphobos2 With or without that -lphobos2 flag, I get errors like these: main.d(.text._Dmain+0x18e): undefined reference to `D3std5stdio16__T7writeln(TAyaZ7writeFAyaZv'
Re: Linking C++ standard library works with GDC... but not DMD. (Linux)
On Thursday, 16 April 2015 at 12:57:12 UTC, Steven Schveighoffer wrote: /usr/include/c++/4.8/iostream:74: undefine reference to `std::ios_base::Init::Init()' (etc.) Try dmd -v to tell you exactly what command it is running for link. Then play around with the link line to see if you can figure out a way to link it correctly. We can work on fixing the situation from there. Maybe there's a way to link using dmd, maybe we have to fix dmd so it allows the correct link call. -Steve Got it!! This is what helped me the most. I compiled a regular C++ program with the -v flag, found where my libstdc++.a was, added it to the command and bam. I really should have thought of this one earlier... Thanks for the quick support, everyone!
Invalid Floating Point Operation (DMD 2067)
Hi Everyone, After I switched to DMD 2067 my code that previously worked began crashing. If I change the return statement in the matrixOrtho function from: return Matrix(...); to: Matrix m = Matrix(...); return m; then the error won't occur anymore. What is going on? Thank you. import std.math; import std.stdio; struct Matrix { float m00, m01, m02, m03; float m10, m11, m12, m13; float m20, m21, m22, m23; float m30, m31, m32, m33; this(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33) nothrow pure @nogc { this.m00 = m00; this.m01 = m01; this.m02 = m02; this.m03 = m03; this.m10 = m10; this.m11 = m11; this.m12 = m12; this.m13 = m13; this.m20 = m20; this.m21 = m21; this.m22 = m22; this.m23 = m23; this.m30 = m30; this.m31 = m31; this.m32 = m32; this.m33 = m33; } } void main(string[] args) { float width = 800f; float height = 600f; float near = -5f; float far = 10f; float hw = width / 2f; float hh = height / 2f; Matrix ortho = matrixOrtho(-hw, hw, -hh, hh, near, far); } Matrix matrixOrtho(float left, float right, float bottom, float top, float near, float far) /* pure @nogc */ { debug { FloatingPointControl fpCtrl; fpCtrl.enableExceptions(FloatingPointControl.severeExceptions); } float doubledNear = near*2f; float farMinusNear = far - near; float rightMinusLeft = right - left; float topMinusBottom = top - bottom; return Matrix(2f / rightMinusLeft, 0f, 0f, -(right + left)/rightMinusLeft, 0f, 2f / topMinusBottom, 0f, -(top + bottom)/topMinusBottom, 0f, 0f, -2f / farMinusNear, -(far + near)/farMinusNear, 0f, 0f, 0f, 1f); //Matrix m = Matrix(2f / rightMinusLeft, 0f, 0f, -(right + left)/rightMinusLeft, // 0f, 2f / topMinusBottom, 0f, -(top + bottom)/topMinusBottom, // 0f, 0f, -2f / farMinusNear, -(far + near)/farMinusNear, // 0f, 0f, 0f, 1f); //return m; } Error report: object.Error@(0): Invalid Floating Point Operation 0x00402340 0x004020E2 0x004029E2 0x004029B7 0x004028CF 0x004022D7 0x758D7C04 in BaseThreadInitThunk 0x77ADB54F in RtlInitializeExceptionChain 0x77ADB51A in RtlInitializeExceptionChain object.Error@(0): Invalid Floating Point Operation 0x00402340 0x004020E2 0x004029E2 0x004029B7 0x004028CF 0x004022D7 0x758D7C04 in BaseThreadInitThunk 0x77ADB54F in RtlInitializeExceptionChain 0x77ADB51A in RtlInitializeExceptionChain object.Error@(0): Invalid Floating Point Operation 0x00406E5B 0x004029C5 0x004028CF 0x004022D7 0x758D7C04 in BaseThreadInitThunk 0x77ADB54F in RtlInitializeExceptionChain 0x77ADB51A in RtlInitializeExceptionChain
Re: Invalid Floating Point Operation (DMD 2067)
On 4/16/15 10:23 AM, ref2401 wrote: Hi Everyone, After I switched to DMD 2067 my code that previously worked began crashing. If I change the return statement in the matrixOrtho function from: return Matrix(...); to: Matrix m = Matrix(...); return m; then the error won't occur anymore. What is going on? Builds and runs fine for me. What is your OS and build command? -Steve
Re: What is the memory usage of my app?
On Thursday, 16 April 2015 at 12:17:24 UTC, Adil wrote: Calling Securities.bytes shows "188 MB", but "ps" shows about 591 MB of Resident memory. Where is the memory usage coming from? What am i missing? I'd say this is memory allocated while you load the CSV file. I can't tell much more without seeing the actual code. Suggestion: Compile with `dmd -vgc` and look where allocations happen, especially in loops.
Re: Invalid Floating Point Operation (DMD 2067)
Builds and runs fine for me. What is your OS and build command? -Steve Win 8.1 dmd main.d -ofmain.exe -debug -unittest -wi if %errorLevel% equ 0 (main.exe)
Re: What is the memory usage of my app?
Fwiw, I have been working on something similar. Others will have more experience on the GC, but perhaps you might find this interesting. For CSV files, what I found is that parsing is quite slow (and memory intensive). So rather than parse the same data every time, I found it helpful to do so once in a batch that runs on a cron job, and write out to msgpack format. I am not a GC expert, but what happens if you run GC.collect() once you are done parsing? auto loadGiltPrices() { auto data=cast(ubyte[])std.file.read("/hist/msgpack/dmo.pack"); return cast(immutable)data.unpack!(GiltPriceFromDMO[][string]); } struct GiltPriceFromDMO { string name; string ISIN; KPDateTime redemptionDate; KPDateTime closeDate; int indexLag; double cleanPrice; double dirtyPrice; double accrued; double yield; double modifiedDuration; } void main(string[] args) { auto gilts=readCSVDMO(); ubyte[] data=pack(gilts); std.file.write("dmo.pack",data); writefln("* done"); data=cast(ubyte[])std.file.read("dmo.pack"); } On Thursday, 16 April 2015 at 12:17:24 UTC, Adil wrote: I've written a simple socket-server app that securities (stock market shares) data and allows clients to query over them. The app starts by loading instrument information from a CSV file into some structs, then listens on a socket responding to queries. It doesn't mutate the data or allocate anything substantial. There are 2 main structs in the app. One stores security data, and the other groups together securities. They are defined as follows : __gshared Securities securities; struct Security { string RIC; string TRBC; string[string] fields; double[string] doubles; @nogc @property pure size_t bytes() { size_t bytes; bytes = RIC.sizeof + RIC.length; bytes += TRBC.sizeof + TRBC.length; foreach(k,v; fields) { bytes += (k.sizeof + k.length + v.sizeof + v.length); } foreach(k, v; doubles) { bytes += (k.sizeof + k.length + v.sizeof); } return bytes + Security.sizeof; } } struct Securities { Security[] securities; private size_t[string] rics; // Store offsets for each TRBC group ulong[2][string] econSect; ulong[2][string] busSect; ulong[2][string] IndGrp; ulong[2][string] Ind; @nogc @property pure size_t bytes() { size_t bytes; foreach(Security s; securities) { bytes += s.sizeof + s.bytes; } foreach(k, v; rics) { bytes += k.sizeof + k.length + v.sizeof; } foreach(k, v; econSect) { bytes += k.sizeof + k.length + v.sizeof; } foreach(k, v; busSect) { bytes += k.sizeof + k.length + v.sizeof; } foreach(k, v; IndGrp) { bytes += k.sizeof + k.length + v.sizeof; } foreach(k, v; Ind) { bytes += k.sizeof + k.length + v.sizeof; } return bytes + Securities.sizeof; } } Calling Securities.bytes shows "188 MB", but "ps" shows about 591 MB of Resident memory. Where is the memory usage coming from? What am i missing?
Re: CT-String as a Symbol
On Thursday, 16 April 2015 at 10:46:25 UTC, John Colvin wrote: On Thursday, 16 April 2015 at 10:27:20 UTC, Per Nordlöw wrote: On Wednesday, 15 April 2015 at 16:21:59 UTC, Nordlöw wrote: Help please. I'm quite satisfied with the current state now. Is anybody interested in having this in typecons.d in Phobos? I would be, yes. Have you considered what happens if you apply it to a type that uses the new opIndex/opSlice semantics? I guess you mean Kenjis multidim array indexing and slicing. If so, I haven't thought of that. I'm very open to suggestions. Is there a way to CT-query the arity of all opIndex and opSlice overloads?
Re: GC: Memory keeps growing
On Wednesday, 15 April 2015 at 12:03:49 UTC, Chris wrote: There might be some low-hanging fruit there. However, before I change anything, maybe you guys have some suggestions. See if switching to 64-bit mode changes anything.
basic question about text file encodings
What is the best way to figure out and then decode a file of unknown coding to dchar? 2½% Index-linked Treasury Stock 2016,GB0009075325,26-Jul-2016,28-Feb-2014,8 month,337.81,338.577874,0.76787400,-1.953546,2.37 Eg I am not sure what encoding the 1/2 is in above, but treating it as utf8 leads to an exception. I will post the answer to the wiki, as it's the typical kind of thing that stumps a newcomer to the language. I can see how to figure out a guess at the file format from Tango, but what do I do with the bytes from std.file.read once I have guessed the encoding? And more generally shouldn't we have an easy solution in Phobos for this common problem (presuming I am not just overlooking what is there?)
Re: basic question about text file encodings
On Thursday, 16 April 2015 at 19:22:41 UTC, Laeeth Isharc wrote: What is the best way to figure out and then decode a file of unknown coding to dchar? You generally can't, though some statistical analysis can sometimes help. The encoding needs to be known through some other means to have a correct conversion. How was the file generated? If it came from Excel it might be in the Windows encoding. You can try my characterencodings.d https://github.com/adamdruppe/arsd/blob/master/characterencodings.d this is a standalone file, just download it and add to your build, and do string utf8 = convertToUtf8Lossy(your_data, "windows-1252"); and it will work, though it might drop a character if it doesn't know how to convert it (hence Lossy in the name). There's also a `convertToUtf8` function which never drops characters it doesn't know. Then examine the string and see if it looks right o you. Alternatively, with Phobos only, you can try: import std.conv, std.encoding; string utf8 = to!string(Windows1252String(your_data)); both my module and the Phobos module expects your input data to be immutable(ubyte)[], so you might need to cast to that. The Phobos moduel is great if you know the type at compile time and it is one of the few encodings it supports. My module is a bit better taking random runtime data (I wrote it to support website and email screen scraping).
Re: basic question about text file encodings
First try utf-8, if it doesn't work, then use some fallback encoding like latin1.
Printing an std.container.Array
Executing this code: import std.container.array; import std.stdio; int main() { writeln(Array!int([1, 2])); return 0; } outputs the following: Array!int(RefCounted!(Payload, cast(RefCountedAutoInitialize)0)(RefCountedStore(B694B0))) The strange thing is that this works fine: import std.container.array; import std.stdio; int main() { writeln(Array!int([1, 2])[0..$]); return 0; } [1, 2] How am I supposed to interpret this?
Re: Printing an std.container.Array
On Thu, 16 Apr 2015 19:55:52 + Bayan Rafeh via Digitalmars-d-learn wrote: > Executing this code: > > import std.container.array; > import std.stdio; > > > int main() { > writeln(Array!int([1, 2])); > return 0; > } > > outputs the following: > > Array!int(RefCounted!(Payload, > cast(RefCountedAutoInitialize)0)(RefCountedStore(B694B0))) > > > The strange thing is that this works fine: > > import std.container.array; > import std.stdio; > > int main() { > writeln(Array!int([1, 2])[0..$]); > return 0; > } > > [1, 2] > > How am I supposed to interpret this? https://github.com/D-Programming-Language/phobos/pull/2875
Re: Printing an std.container.Array
On Thu, Apr 16, 2015 at 07:55:52PM +, Bayan Rafeh via Digitalmars-d-learn wrote: > Executing this code: > > import std.container.array; > import std.stdio; > > > int main() { > writeln(Array!int([1, 2])); > return 0; > } > > outputs the following: > > Array!int(RefCounted!(Payload, > cast(RefCountedAutoInitialize)0)(RefCountedStore(B694B0))) > > > The strange thing is that this works fine: > > import std.container.array; > import std.stdio; > > int main() { > writeln(Array!int([1, 2])[0..$]); > return 0; > } > > [1, 2] > > How am I supposed to interpret this? Try slicing the Array before passing it to writeln? writeln(Array!int([1, 2])[]); Basically, there is a distinction between a container and a range that spans the items in a container. The conventional syntax for getting a range over a container's contents is the slicing operator []. T -- It said to install Windows 2000 or better, so I installed Linux instead.
Re: About @ and UDA
On Wednesday, 15 April 2015 at 16:59:12 UTC, ketmar wrote: or make "safe" and company "context keywords". along with "body" (oh, how i hate the unabilily to declare "body" member!") Ugh, yeah. Makes physics code awkward.
Re: Printing an std.container.Array
On Thursday, 16 April 2015 at 19:55:53 UTC, Bayan Rafeh wrote: How am I supposed to interpret this? The array contains two elements. The first equals one and the second equals two. What happens under the hood is that Array does no provide a toString method, instead a default is used. This results in your first output. For ranges - and the slice of the array is a range while the array is not - writeln prints the elements as a special case which leads to your second output.
Re: Printing an std.container.Array
On Thu, 16 Apr 2015 13:05:48 -0700 "H. S. Teoh via Digitalmars-d-learn" wrote: > On Thu, Apr 16, 2015 at 07:55:52PM +, Bayan Rafeh via Digitalmars-d-learn > wrote: > > Executing this code: > > > > import std.container.array; > > import std.stdio; > > > > > > int main() { > > writeln(Array!int([1, 2])); > > return 0; > > } > > > > outputs the following: > > > > Array!int(RefCounted!(Payload, > > cast(RefCountedAutoInitialize)0)(RefCountedStore(B694B0))) > > > > > > The strange thing is that this works fine: > > > > import std.container.array; > > import std.stdio; > > > > int main() { > > writeln(Array!int([1, 2])[0..$]); > > return 0; > > } > > > > [1, 2] > > > > How am I supposed to interpret this? > > Try slicing the Array before passing it to writeln? > > writeln(Array!int([1, 2])[]); > > Basically, there is a distinction between a container and a range that > spans the items in a container. The conventional syntax for getting a > range over a container's contents is the slicing operator []. > > > T > Yep, but problem is almost no one expect this, or know this. We definitely should do better.
Re: About @ and UDA
On Thursday, 16 April 2015 at 20:09:07 UTC, Vlad Levenfeld wrote: On Wednesday, 15 April 2015 at 16:59:12 UTC, ketmar wrote: or make "safe" and company "context keywords". along with "body" (oh, how i hate the unabilily to declare "body" member!") Ugh, yeah. Makes physics code awkward. And DOM.
Re: Printing an std.container.Array
Yep, but problem is almost no one expect this, or know this. We definitely should do better. How?
Re: Invalid Floating Point Operation (DMD 2067)
On Thursday, 16 April 2015 at 15:00:39 UTC, ref2401 wrote: Builds and runs fine for me. What is your OS and build command? -Steve Win 8.1 dmd main.d -ofmain.exe -debug -unittest -wi if %errorLevel% equ 0 (main.exe) Reduced case: struct S { float f; }
Re: Printing an std.container.Array
On 4/16/15 4:18 PM, Panke wrote: Yep, but problem is almost no one expect this, or know this. We definitely should do better. How? By doing what is expected. Print the array contents. See my new comment in that PR. -Steve
Re: Invalid Floating Point Operation (DMD 2067)
On Thursday, 16 April 2015 at 20:27:46 UTC, rumbu wrote: Hit send by accident :) Reduced case: struct S { float f; //or double or real this(float f) { this.f = f; } } S foo() { return S(0f); } void main() { auto s = foo(); } Win 8.1 also, 32 and 64 bit, debug or release, same exception
Re: What is the memory usage of my app?
On Thursday, 16 April 2015 at 17:13:25 UTC, Laeeth Isharc wrote: For CSV files, what I found is that parsing is quite slow (and memory intensive). If your sure that CSV reading is the culprit, writing a custom parser could help. It's possible to load a CSV file with almost no memory overhead. What I would do: - Use std.mmfile with Mode.readCopyOnWrite to map the file into memory. - Iterate over the lines, and then over the fields using std.algorithm.splitter. - Don't copy, but return slices into the mapped memory. - If a field needs to be unescaped, this can be done in-place. Unescaping never makes a string longer, and the original file won't be modified thanks to COW (private mapping).
Re: Invalid Floating Point Operation (DMD 2067)
On 4/16/15 4:32 PM, rumbu wrote: On Thursday, 16 April 2015 at 20:27:46 UTC, rumbu wrote: Hit send by accident :) Reduced case: struct S { float f; //or double or real this(float f) { this.f = f; } } S foo() { return S(0f); } void main() { auto s = foo(); } Win 8.1 also, 32 and 64 bit, debug or release, same exception Thanks, please file a bug, make it Windows specific, as I did not get the exception on OSX. -Steve
Re: Invalid Floating Point Operation (DMD 2067)
Thanks, please file a bug, make it Windows specific, as I did not get the exception on OSX. -Steve Done: https://issues.dlang.org/show_bug.cgi?id=14452
Re: Printing an std.container.Array
On Thursday, 16 April 2015 at 20:34:19 UTC, Steven Schveighoffer wrote: On 4/16/15 4:18 PM, Panke wrote: Yep, but problem is almost no one expect this, or know this. We definitely should do better. How? By doing what is expected. Print the array contents. See my new comment in that PR. -Steve I think that this action should print the contents of the container, not it's type, ie [1, 2, 3, 4]: import std.stdio : writeln; import std.container.rbtree : redBlackTree; void main() { auto a = redBlackTree(1, 2, 1, 3, 4, 3); writeln(a); // std.container.rbtree.RedBlackTree!(int, "a < b", false).RedBlackTree } Will it be modified in future versions of DMD?
Re: Printing an std.container.Array
On Thu, 16 Apr 2015 20:18:40 + Panke via Digitalmars-d-learn wrote: > > > > Yep, but problem is almost no one expect this, or know this. We > > definitely > > should do better. > > How? Improve doc at least. But it would be fine to have something like dump function (equivalent of php var_dump)