why the sort result is different with C#

2016-01-21 Thread mzfhhhh via Digitalmars-d-learn
D code: auto arr = ["b1=1", "b=2","a1=1", "a=2"]; writeln(arr.sort()); output:["a1=1", "a=2", "b1=1", "b=2"] C# code: var arr = new string[]{ "b1=1", "b=2", "a1=1", "a=2" }; Array.Sort(arr); output:["a=2","a1=1","b=2","b1=1"]

D ASM. Program fails

2016-01-21 Thread Iakh via Digitalmars-d-learn
This code compiles but program exits with code -11 What's wrong? import std.stdio; import core.simd; int pmovmskb(inout byte16 v) { asm { movdqa XMM0, v; pmovmskb EAX, XMM0; ret; } } void main() { byte16 a = [-1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

Re: Disabling GC in D

2016-01-21 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 21 January 2016 at 23:06:55 UTC, Dibyendu Majumdar wrote: On Thursday, 21 January 2016 at 22:44:14 UTC, H. S. Teoh wrote: Hi - I want to be sure that my code is not allocating memory via the GC allocator; but when shipping I don't need to disable GC - it is mostly a development che

Re: Linking C libraries with DMD

2016-01-21 Thread jmh530 via Digitalmars-d-learn
On Friday, 22 January 2016 at 04:03:27 UTC, Mike Parker wrote: [snip] Thanks for the detailed reply.

Re: Linking C libraries with DMD

2016-01-21 Thread Mike Parker via Digitalmars-d-learn
I've take your example, modified it slightly, compiled the DLL with Visual Studio, and got a working executable. Firs up, the C file. Here's your original: clib.c #include int some_c_function(int); int some_c_function(int a) { printf("Hello, D! from C! %d\n", a);

Re: Linking C libraries with DMD

2016-01-21 Thread Mike Parker via Digitalmars-d-learn
On Friday, 22 January 2016 at 02:39:33 UTC, jmh530 wrote: The LearningD book says that you should compile the libraries with DMC on Windows, but I can't figure out how to generate a shared library on DMC. I didn't get the implib error for what I was working on before. I feel like getting s

Is memory-safe IO possible?

2016-01-21 Thread Chris Wright via Digitalmars-d-learn
I want everything I do to be memory-safe insofar as possible. One of the things I'm doing is communicating to REST services using std.net.curl. std.net.curl isn't marked @safe or @trusted. Is it possible to have properly memory-safe IO?

Re: Linking C libraries with DMD

2016-01-21 Thread bachmeier via Digitalmars-d-learn
On Friday, 22 January 2016 at 02:39:33 UTC, jmh530 wrote: I tried to create an example that more closely resembles what is in LearningD (see https://github.com/aldacron/LearningD/tree/master/Chapter09_Connecting%20D%20with%20C/clib). I created two files clib.c #include int s

Re: How to represent struct with trailing array member

2016-01-21 Thread bearophile via Digitalmars-d-learn
Dibyendu Majumdar: On Thursday, 21 January 2016 at 21:52:06 UTC, Dibyendu Majumdar wrote: How should this be translated to D? Will D's array access allow data elements to be accessed beyond the size declared? Take a look at the code I've written here: http://rosettacode.org/wiki/Sokoban#Faste

Re: Linking C libraries with DMD

2016-01-21 Thread jmh530 via Digitalmars-d-learn
On Friday, 22 January 2016 at 01:34:00 UTC, bachmeier wrote: Have you used pragma(lib)? https://dlang.org/spec/pragma.html#lib There's also a section on it in Learning D. Looks like the sections are split apart by a couple hundred pages. I tried it with the .lib I created earlier without

Re: Speed of csvReader

2016-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 21, 2016 at 04:50:12PM -0800, H. S. Teoh via Digitalmars-d-learn wrote: > [...] > > > https://github.com/quickfur/fastcsv [...] Fixed some boundary condition crashes and reverted doubled quote handling in unquoted fields (since those are illegal according to RFC 4810). Performance

Re: Linking C libraries with DMD

2016-01-21 Thread jmh530 via Digitalmars-d-learn
On Friday, 22 January 2016 at 00:43:05 UTC, W.J. wrote: The GNU linker ld, for instance, uses the -l switch for adding libraries to link against and -L to add a search path to look for the libraries passed in with -l. If you leave it to the compiler to invoke the linker you need to remembe

Re: How to represent struct with trailing array member

2016-01-21 Thread Chris Wright via Digitalmars-d-learn
On Thu, 21 Jan 2016 21:52:06 +, Dibyendu Majumdar wrote: > Hi > > I have C code where the struct has a trailing array member: > > struct matrix { >int rows; >int cols; >double data[1]; > }; > > In C code this is allocated dynamically to be variable size. The array > is used just

Re: writeln wipes contents of variables ?

2016-01-21 Thread anonymous via Digitalmars-d-learn
On 22.01.2016 01:49, W.J. wrote: How can I identify those ranges, or, how can I tell if any particular range has value semantics ? I didn't read any of this in the manual - not that I could remember anyways. Generally you shouldn't. If you care about it either way, use .save or std.range.refRa

Re: writeln wipes contents of variables ?

2016-01-21 Thread Rikki Cattermole via Digitalmars-d-learn
On 22/01/16 5:45 AM, W.J. wrote: On Thursday, 21 January 2016 at 14:36:36 UTC, Rikki Cattermole wrote: On 22/01/16 3:07 AM, W.J. wrote: On Thursday, 21 January 2016 at 13:15:46 UTC, Rikki Cattermole wrote: [...] Thanks for your reply. So writeln consumes the values in an InputRange. That l

Re: Speed of csvReader

2016-01-21 Thread cym13 via Digitalmars-d-learn
On Friday, 22 January 2016 at 01:27:13 UTC, H. S. Teoh wrote: And now that you mention this, RFC-4180 does not allow doubled quotes in an unquoted field. I'll take that out of the code (it improves performance :-D). Right, re-reading the RFC would have been a great thing. That said I saw that

Re: Linking C libraries with DMD

2016-01-21 Thread bachmeier via Digitalmars-d-learn
On Thursday, 21 January 2016 at 23:07:06 UTC, jmh530 wrote: I ran dmd -m64 .d -L/LIBPATH: -L and got : fatal error LNK1136: invalid or corrupt file --- errorlevel 1136 At least that's progress. LNK1136 is for a corrupt or abnormally small file. I did notice that the original dll was 82kb a

Re: Template specialization

2016-01-21 Thread Darrell Gallion via Digitalmars-d-learn
On Friday, 22 January 2016 at 00:08:56 UTC, Ali Çehreli wrote: On 01/21/2016 03:37 PM, Darrell Gallion wrote: How do you create a template that accepts many types. But overrides just one of them? Don't want to write out all of the specializations. Hours of google and I'm sure it's simple... -=

Re: htod question

2016-01-21 Thread W.J. via Digitalmars-d-learn
On Friday, 22 January 2016 at 01:04:50 UTC, Dibyendu Majumdar wrote: On Friday, 22 January 2016 at 01:03:09 UTC, Dibyendu Majumdar wrote: On Friday, 22 January 2016 at 00:52:59 UTC, W.J. wrote: Counter question: What's so bad about the D std library ? I am trying to create bindings for existi

Re: Speed of csvReader

2016-01-21 Thread cym13 via Digitalmars-d-learn
On Friday, 22 January 2016 at 01:14:48 UTC, Jesse Phillips wrote: On Friday, 22 January 2016 at 00:56:02 UTC, cym13 wrote: Great! Sorry for the separator thing, I didn't read your code carefully. You still lack some things like comments and surely more things that I don't know about but it's ge

Re: Speed of csvReader

2016-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 22, 2016 at 01:13:07AM +, Jesse Phillips via Digitalmars-d-learn wrote: > On Thursday, 21 January 2016 at 23:03:23 UTC, cym13 wrote: > >but in that case external quotes aren't required: > > > >number,name,price,comment > >1,Twilight,150,good friend > >2,Fluttershy,142,g

Re: Speed of csvReader

2016-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 22, 2016 at 12:56:02AM +, cym13 via Digitalmars-d-learn wrote: [...] > Great! Sorry for the separator thing, I didn't read your code > carefully. You still lack some things like comments and surely more > things that I don't know about but it's getting there. Comments? You mean in

Re: Speed of csvReader

2016-01-21 Thread Jesse Phillips via Digitalmars-d-learn
On Friday, 22 January 2016 at 00:56:02 UTC, cym13 wrote: Great! Sorry for the separator thing, I didn't read your code carefully. You still lack some things like comments and surely more things that I don't know about but it's getting there. I didn't think you'd go through the trouble of fixing

Re: Speed of csvReader

2016-01-21 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 21 January 2016 at 23:03:23 UTC, cym13 wrote: but in that case external quotes aren't required: number,name,price,comment 1,Twilight,150,good friend 2,Fluttershy,142,gentle 3,Pinkie Pie,169,He said ""oh my gosh"" std.csv will reject this. If validation is turned of

Re: htod question

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Friday, 22 January 2016 at 00:52:59 UTC, W.J. wrote: Counter question: What's so bad about the D std library ? I am trying to create bindings for existing C library so I was trying to use htod for that.

Re: htod question

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Friday, 22 January 2016 at 01:03:09 UTC, Dibyendu Majumdar wrote: On Friday, 22 January 2016 at 00:52:59 UTC, W.J. wrote: Counter question: What's so bad about the D std library ? I am trying to create bindings for existing C library so I was trying to use htod for that. The library incl

Re: Speed of csvReader

2016-01-21 Thread cym13 via Digitalmars-d-learn
On Friday, 22 January 2016 at 00:26:16 UTC, H. S. Teoh wrote: On Thu, Jan 21, 2016 at 11:03:23PM +, cym13 via Digitalmars-d-learn wrote: [...] Alright, I decided to take on the challenge to write a "real" CSV parser... since it's a bit tedious to keep posting code in the forum, I've push

Re: htod question

2016-01-21 Thread W.J. via Digitalmars-d-learn
On Friday, 22 January 2016 at 00:31:01 UTC, Dibyendu Majumdar wrote: I tried using htod but got errors as it could not handle the std C header files (Visual C++). And probably never will. D doesn't have a preprocessor so it's kind of hard to automate the process. How do people work around t

Re: Speed of csvReader

2016-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 21, 2016 at 04:31:03PM -0800, H. S. Teoh via Digitalmars-d-learn wrote: > On Thu, Jan 21, 2016 at 04:26:16PM -0800, H. S. Teoh via Digitalmars-d-learn > wrote: [...] > > https://github.com/quickfur/fastcsv > > Oh, forgot to mention, the parsing times are still lightning fast > af

Re: writeln wipes contents of variables ?

2016-01-21 Thread W.J. via Digitalmars-d-learn
On Thursday, 21 January 2016 at 21:59:10 UTC, Chris Wright wrote: On Thu, 21 Jan 2016 14:07:16 +, W.J. wrote: So writeln consumes the values in an InputRange. That leads me to believe that if I feed an InputRange to foreach, it will consume the values, too. Did I get that right ? In gene

Re: Linking C libraries with DMD

2016-01-21 Thread W.J. via Digitalmars-d-learn
On Thursday, 21 January 2016 at 23:07:06 UTC, jmh530 wrote: On Thursday, 21 January 2016 at 22:54:26 UTC, Dibyendu Majumdar wrote: On Thursday, 21 January 2016 at 22:49:06 UTC, jmh530 wrote: I'm not trying to created a shared library in D. My goal is to use a shared library from C in D. Right

Re: Speed of csvReader

2016-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 21, 2016 at 04:26:16PM -0800, H. S. Teoh via Digitalmars-d-learn wrote: > On Thu, Jan 21, 2016 at 11:03:23PM +, cym13 via Digitalmars-d-learn wrote: > > On Thursday, 21 January 2016 at 21:24:49 UTC, H. S. Teoh wrote: > > >[...] > > > > It may be fast but I think it may be related

htod question

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
I tried using htod but got errors as it could not handle the std C header files (Visual C++). How do people work around this? Thanks and Regards Dibyendu

Re: Speed of csvReader

2016-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 21, 2016 at 11:03:23PM +, cym13 via Digitalmars-d-learn wrote: > On Thursday, 21 January 2016 at 21:24:49 UTC, H. S. Teoh wrote: > >[...] > > It may be fast but I think it may be related to the fact that this is > not a CSV parser. Don't get me wrong, it is able to parse a format >

Re: Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 January 2016 at 23:58:35 UTC, H. S. Teoh wrote: are there flags that I should be compiling with or some other thing that I am missing? Did you supply a main() function? If not, it won't run, because fastcsv.d is only a module. If you want to run the benchmark, you'll have to

Re: Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 January 2016 at 23:58:35 UTC, H. S. Teoh wrote: On Thu, Jan 21, 2016 at 11:29:49PM +, data pulverizer via Digitalmars-d-learn wrote: On Thursday, 21 January 2016 at 21:24:49 UTC, H. S. Teoh wrote: >On Thu, Jan 21, 2016 at 07:11:05PM +, Jesse Phillips via >This piqued my

Re: Template specialization

2016-01-21 Thread Ali Çehreli via Digitalmars-d-learn
On 01/21/2016 03:37 PM, Darrell Gallion wrote: How do you create a template that accepts many types. But overrides just one of them? Don't want to write out all of the specializations. Hours of google and I'm sure it's simple... -=Darrell The straightforward approach is tricky because the ':

Re: Template specialization

2016-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 21, 2016 at 11:37:34PM +, Darrell Gallion via Digitalmars-d-learn wrote: > How do you create a template that accepts many types. > But overrides just one of them? > Don't want to write out all of the specializations. > > Hours of google and I'm sure it's simple... [...] I'm afrai

Re: Speed of csvReader

2016-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 21, 2016 at 11:29:49PM +, data pulverizer via Digitalmars-d-learn wrote: > On Thursday, 21 January 2016 at 21:24:49 UTC, H. S. Teoh wrote: > >On Thu, Jan 21, 2016 at 07:11:05PM +, Jesse Phillips via This piqued > >my interest today, so I decided to take a shot at writing a fast

Re: Speed of csvReader

2016-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 21, 2016 at 11:03:23PM +, cym13 via Digitalmars-d-learn wrote: > On Thursday, 21 January 2016 at 21:24:49 UTC, H. S. Teoh wrote: > >[...] > > It may be fast but I think it may be related to the fact that this is > not a CSV parser. Don't get me wrong, it is able to parse a format >

Re: Speed of csvReader

2016-01-21 Thread Jon D via Digitalmars-d-learn
On Thursday, 21 January 2016 at 22:20:28 UTC, H. S. Teoh wrote: On Thu, Jan 21, 2016 at 10:09:24PM +, Jon D via Digitalmars-d-learn wrote: [...] FWIW - I've been implementing a few programs manipulating delimited files, e.g. tab-delimited. Simpler than CSV files because there is no escaping

Template specialization

2016-01-21 Thread Darrell Gallion via Digitalmars-d-learn
How do you create a template that accepts many types. But overrides just one of them? Don't want to write out all of the specializations. Hours of google and I'm sure it's simple... -=Darrell

Re: Doubt - Static multidimension arrays

2016-01-21 Thread tsbockman via Digitalmars-d-learn
On Thursday, 21 January 2016 at 01:36:21 UTC, Nemo wrote: I don't remember where I saw it, but actually, in static multi-dimensional arrays, arr[0][1] is next to arr[0][0] in memory. You can see it with: void main () { ubyte [7][5] arr; import std.stdio : writeln; writeln ( & arr[0][0],

Re: Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 January 2016 at 21:24:49 UTC, H. S. Teoh wrote: On Thu, Jan 21, 2016 at 07:11:05PM +, Jesse Phillips via This piqued my interest today, so I decided to take a shot at writing a fast CSV parser. First, I downloaded a sample large CSV file from: [...] Hi H. S. Teoh, I tried

Re: Linking C libraries with DMD

2016-01-21 Thread jmh530 via Digitalmars-d-learn
On Thursday, 21 January 2016 at 22:54:26 UTC, Dibyendu Majumdar wrote: On Thursday, 21 January 2016 at 22:49:06 UTC, jmh530 wrote: I'm not trying to created a shared library in D. My goal is to use a shared library from C in D. Right now, I'm working with a simple test case to make sure I cou

Re: Disabling GC in D

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Thursday, 21 January 2016 at 22:44:14 UTC, H. S. Teoh wrote: Hi - I want to be sure that my code is not allocating memory via the GC allocator; but when shipping I don't need to disable GC - it is mostly a development check. I want to manage all memory allocation manually via malloc/free.

Re: Speed of csvReader

2016-01-21 Thread cym13 via Digitalmars-d-learn
On Thursday, 21 January 2016 at 21:24:49 UTC, H. S. Teoh wrote: [...] It may be fast but I think it may be related to the fact that this is not a CSV parser. Don't get me wrong, it is able to parse a format defined by delimiters but true CSV is one hell of a beast. Of course most data look l

Re: Linking C libraries with DMD

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Thursday, 21 January 2016 at 22:49:06 UTC, jmh530 wrote: I'm not trying to created a shared library in D. My goal is to use a shared library from C in D. Right now, I'm working with a simple test case to make sure I could understand it before working with the actual shared library I want t

Re: Linking C libraries with DMD

2016-01-21 Thread jmh530 via Digitalmars-d-learn
I also added an enhancement request: https://issues.dlang.org/show_bug.cgi?id=15588

Re: Linking C libraries with DMD

2016-01-21 Thread jmh530 via Digitalmars-d-learn
On Thursday, 21 January 2016 at 22:35:29 UTC, Dibyendu Majumdar wrote: Sorry the option should be -L/IMPLIB:.. - with single slash but you only need this if you are trying to create a shared library which presumably you are not? I believe to create a static library you need to use -lib, else

Re: Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 January 2016 at 20:46:15 UTC, Gerald Jansen wrote: On Thursday, 21 January 2016 at 09:39:30 UTC, data pulverizer wrote: I have been reading large text files with D's csv file reader and have found it slow compared to R's read.table function This great blog post has an optimized

Re: Disabling GC in D

2016-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 21, 2016 at 10:43:31PM +, Dibyendu Majumdar via Digitalmars-d-learn wrote: > On Thursday, 21 January 2016 at 22:34:43 UTC, cym13 wrote: > >Out of curiosity, why would you force not being able to allocate > >memory? > > Hi - I want to be sure that my code is not allocating memory v

Re: Disabling GC in D

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Thursday, 21 January 2016 at 22:34:43 UTC, cym13 wrote: Out of curiosity, why would you force not being able to allocate memory? Hi - I want to be sure that my code is not allocating memory via the GC allocator; but when shipping I don't need to disable GC - it is mostly a development chec

Re: Grouping variadic parameter tuples on offset and stride

2016-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 21, 2016 at 10:24:55PM +, Nordlöw via Digitalmars-d-learn wrote: [...] > I'm currently only lacking one thing ...namely a way to group the > parameters of the call to a variadic function based on their offset > and stride. That is if have > > haystack.substitute(x0, y0, >

Re: Linking C libraries with DMD

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Thursday, 21 January 2016 at 22:23:36 UTC, jmh530 wrote: Thanks. I had been trying to get 32bit code to work. I don't think I did anything special with gcc to compile the dll as 64bit. Anyway, this is what I get when I try it again (stuff in brackets I replaced). C:>dmd -m64 .d -L/LIBPATH:

Re: Disabling GC in D

2016-01-21 Thread cym13 via Digitalmars-d-learn
On Thursday, 21 January 2016 at 22:20:13 UTC, Dibyendu Majumdar wrote: On Thursday, 21 January 2016 at 22:15:13 UTC, Chris Wright wrote: Finally, you can use gc_setProxy() with a a GC proxy you create. Have it throw an exception instead of allocating. That means you will get crashes instead o

Re: Speed of csvReader

2016-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 21, 2016 at 10:09:24PM +, Jon D via Digitalmars-d-learn wrote: [...] > FWIW - I've been implementing a few programs manipulating delimited > files, e.g. tab-delimited. Simpler than CSV files because there is no > escaping inside the data. I've been trying to do this in relatively >

Grouping variadic parameter tuples on offset and stride

2016-01-21 Thread Nordlöw via Digitalmars-d-learn
I'm currently developing a new lazy variadic generic range/algorithm substitute() at https://github.com/nordlow/justd/blob/master/substitution.d#L261 I plan to propose for Phobos. It is meant to be used as assert(`do_it`.substitute(`_`, ` `, `d`, `g`,

Re: Disabling GC in D

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Thursday, 21 January 2016 at 22:15:13 UTC, Chris Wright wrote: Finally, you can use gc_setProxy() with a a GC proxy you create. Have it throw an exception instead of allocating. That means you will get crashes instead of memory leaks if something uses the GC when it shouldn't. gc_setProx

Re: Linking C libraries with DMD

2016-01-21 Thread jmh530 via Digitalmars-d-learn
On Thursday, 21 January 2016 at 22:14:25 UTC, Dibyendu Majumdar wrote: On Thursday, 21 January 2016 at 22:09:47 UTC, jmh530 wrote: The -L/LIBPATH:c:\lib gives me an error that OPTLINK : Warning 9: Unknown Option : LIBPATH and then gives the path I put is not found. At least when it's outputting

Re: Disabling GC in D

2016-01-21 Thread Chris Wright via Digitalmars-d-learn
On Thu, 21 Jan 2016 21:54:36 +, Dibyendu Majumdar wrote: > Is there a way to disable GC in D? > I am aware of the @nogc qualifier but I would like to completely disable > GC for the whole app/library. > > Regards Dibyendu In order to suppress GC collections, you can call core.memory.GC.disab

Re: Speed of csvReader

2016-01-21 Thread Brad Anderson via Digitalmars-d-learn
On Thursday, 21 January 2016 at 22:13:38 UTC, Brad Anderson wrote: On Thursday, 21 January 2016 at 21:24:49 UTC, H. S. Teoh wrote: [...] What about wrapping the slices in a range-like interface that would unescape the quotes on demand? You could even set a flag on it during the initial pass

Re: Linking C libraries with DMD

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Thursday, 21 January 2016 at 22:09:47 UTC, jmh530 wrote: The -L/LIBPATH:c:\lib gives me an error that OPTLINK : Warning 9: Unknown Option : LIBPATH and then gives the path I put is not found. At least when it's outputting the text, it's combining :C:\lib\yourlib.lib so it seemingly is finding

Re: Disabling GC in D

2016-01-21 Thread cym13 via Digitalmars-d-learn
On Thursday, 21 January 2016 at 21:54:36 UTC, Dibyendu Majumdar wrote: Is there a way to disable GC in D? I am aware of the @nogc qualifier but I would like to completely disable GC for the whole app/library. Regards Dibyendu You should read the core.memory.GC section ( http://dlang.org/pho

Re: Speed of csvReader

2016-01-21 Thread Brad Anderson via Digitalmars-d-learn
On Thursday, 21 January 2016 at 21:24:49 UTC, H. S. Teoh wrote: [snip] There are some limitations to this approach: while the current code does try to unwrap quoted values in the CSV, it does not correctly parse escaped double quotes ("") in the fields. This is because to process those values

Re: Linking C libraries with DMD

2016-01-21 Thread jmh530 via Digitalmars-d-learn
On Thursday, 21 January 2016 at 22:02:57 UTC, Dibyendu Majumdar wrote: On Thursday, 21 January 2016 at 21:55:10 UTC, jmh530 wrote: For the latter - on Windows 10 b64-bit - I am using following options for example: -shared -L/LIBPATH:c:\\lib -L//IMPLIB:mylib.lib I'm not having any luck us

Re: Speed of csvReader

2016-01-21 Thread Jon D via Digitalmars-d-learn
On Thursday, 21 January 2016 at 09:39:30 UTC, data pulverizer wrote: I have been reading large text files with D's csv file reader and have found it slow compared to R's read.table function which is not known to be particularly fast. FWIW - I've been implementing a few programs manipulating d

Re: Linking C libraries with DMD

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Thursday, 21 January 2016 at 21:55:10 UTC, jmh530 wrote: For the latter - on Windows 10 b64-bit - I am using following options for example: -shared -L/LIBPATH:c:\\lib -L//IMPLIB:mylib.lib I'm not having any luck using your options with dmd either (excluding -shared because I don't nee

Re: Disabling GC in D

2016-01-21 Thread Brad Anderson via Digitalmars-d-learn
On Thursday, 21 January 2016 at 21:54:36 UTC, Dibyendu Majumdar wrote: Is there a way to disable GC in D? I am aware of the @nogc qualifier but I would like to completely disable GC for the whole app/library. Regards Dibyendu GC.disable(); This prevents the garbage collector from running bu

Re: Linking C libraries with DMD

2016-01-21 Thread jmh530 via Digitalmars-d-learn
On Thursday, 21 January 2016 at 21:39:08 UTC, Dibyendu Majumdar wrote: Hi I am also new to D and trying to do similar things - i.e. call a shared library written in C from D, but also create a shared library in D. For the latter - on Windows 10 b64-bit - I am using following options for exa

Re: writeln wipes contents of variables ?

2016-01-21 Thread Chris Wright via Digitalmars-d-learn
On Thu, 21 Jan 2016 14:07:16 +, W.J. wrote: > So writeln consumes the values in an InputRange. That leads me to > believe that if I feed an InputRange to foreach, it will consume the > values, too. > Did I get that right ? In general, yes. Some ranges have value semantics and can be saved sim

Disabling GC in D

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
Is there a way to disable GC in D? I am aware of the @nogc qualifier but I would like to completely disable GC for the whole app/library. Regards Dibyendu

How to represent struct with trailing array member

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
Hi I have C code where the struct has a trailing array member: struct matrix { int rows; int cols; double data[1]; }; In C code this is allocated dynamically to be variable size. The array is used just as normal. How should this be translated to D? Will D's array access allow data ele

Re: Speed of csvReader

2016-01-21 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 21 January 2016 at 21:24:49 UTC, H. S. Teoh wrote: Of course, running without GC collection is not a fair comparison with std.csv, so I added an option to my benchmark program to disable the GC for std.csv as well. While the result was slightly faster, it was still much slower tha

Re: Linking C libraries with DMD

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Thursday, 21 January 2016 at 16:14:40 UTC, jmh530 wrote: I'm trying to understand calling C libraries from D on Windows with DMD. I made a simple example and compiled it with a static library fine (so I've converted the .h file correctly). Then, I compiled with gcc to a shared library (becau

Re: Speed of csvReader

2016-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 21, 2016 at 07:11:05PM +, Jesse Phillips via Digitalmars-d-learn wrote: > On Thursday, 21 January 2016 at 09:39:30 UTC, data pulverizer wrote: > >R takes about half as long to read the file. Both read the data in > >the "equivalent" type format. Am I doing something incorrect here?

Re: Speed of csvReader

2016-01-21 Thread Gerald Jansen via Digitalmars-d-learn
On Thursday, 21 January 2016 at 09:39:30 UTC, data pulverizer wrote: I have been reading large text files with D's csv file reader and have found it slow compared to R's read.table function This great blog post has an optimized FastReader for CSV files: http://tech.adroll.com/blog/data/2014/11

Re: Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 January 2016 at 19:08:38 UTC, data pulverizer wrote: On Thursday, 21 January 2016 at 18:46:03 UTC, Justin Whear wrote: On Thu, 21 Jan 2016 18:37:08 +, data pulverizer wrote: It's interesting that the output first array is not the same as the input byLine reuses a buffer (

Re: Speed of csvReader

2016-01-21 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 21 January 2016 at 09:39:30 UTC, data pulverizer wrote: R takes about half as long to read the file. Both read the data in the "equivalent" type format. Am I doing something incorrect here? CsvReader hasn't been compared and optimized from other CSV readers. It does have allocati

Re: Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 January 2016 at 18:46:03 UTC, Justin Whear wrote: On Thu, 21 Jan 2016 18:37:08 +, data pulverizer wrote: It's interesting that the output first array is not the same as the input byLine reuses a buffer (for speed) and the subsequent split operation just returns slices int

Re: Speed of csvReader

2016-01-21 Thread Justin Whear via Digitalmars-d-learn
On Thu, 21 Jan 2016 18:37:08 +, data pulverizer wrote: > It's interesting that the output first array is not the same as the > input byLine reuses a buffer (for speed) and the subsequent split operation just returns slices into that buffer. So when byLine progresses to the next line the s

Re: Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 January 2016 at 18:31:17 UTC, data pulverizer wrote: Good news and bad new. I was going for something similar to what you have above and both slash the time alot: Time (s): 1.024 But now the output is a little garbled. For some reason the splitter isn't splitting correctly - o

Re: Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 January 2016 at 17:17:52 UTC, Saurabh Das wrote: On Thursday, 21 January 2016 at 17:10:39 UTC, data pulverizer wrote: On Thursday, 21 January 2016 at 16:01:33 UTC, wobbles wrote: Interesting that reading a file is so slow. Your timings from R, is that including reading the file

Re: Linking C libraries with DMD

2016-01-21 Thread jmh530 via Digitalmars-d-learn
On Thursday, 21 January 2016 at 16:57:26 UTC, W.J. wrote: You need to port the header file to d. i believe there's the htod utility, however I haven't used that yet. Then, basically all you have to do is to tell the linker to link against your C .lib. Remember that -LC:\folder (for dmd) passes

Re: Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 January 2016 at 16:25:55 UTC, bachmeier wrote: On Thursday, 21 January 2016 at 10:48:15 UTC, data pulverizer wrote: Running Ubuntu 14.04 LTS In that case, have you looked at http://lancebachmeier.com/rdlang/ If this is a serious bottleneck you can solve it with two lines e

Re: Speed of csvReader

2016-01-21 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 21 January 2016 at 17:10:39 UTC, data pulverizer wrote: On Thursday, 21 January 2016 at 16:01:33 UTC, wobbles wrote: Interesting that reading a file is so slow. Your timings from R, is that including reading the file also? Yes, its just insane isn't it? It is insane. Earlier in

Re: Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 January 2016 at 16:01:33 UTC, wobbles wrote: Interesting that reading a file is so slow. Your timings from R, is that including reading the file also? Yes, its just insane isn't it?

Re: Linking C libraries with DMD

2016-01-21 Thread W.J. via Digitalmars-d-learn
On Thursday, 21 January 2016 at 17:00:14 UTC, Andrea Fontana wrote: On Thursday, 21 January 2016 at 16:57:26 UTC, W.J. wrote: You need to port the header file to d. i believe there's the htod utility, however I haven't used that yet. You should try with dstep too. More info here: http://wiki.

Re: Linking C libraries with DMD

2016-01-21 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 21 January 2016 at 16:57:26 UTC, W.J. wrote: You need to port the header file to d. i believe there's the htod utility, however I haven't used that yet. You should try with dstep too. More info here: http://wiki.dlang.org/List_of_Bindings And here: http://wiki.dlang.org/D_binding

Re: Linking C libraries with DMD

2016-01-21 Thread W.J. via Digitalmars-d-learn
On Thursday, 21 January 2016 at 16:14:40 UTC, jmh530 wrote: I'm trying to understand calling C libraries from D on Windows with DMD. I made a simple example and compiled it with a static library fine (so I've converted the .h file correctly). Then, I compiled with gcc to a shared library (becau

Re: writeln wipes contents of variables ?

2016-01-21 Thread W.J. via Digitalmars-d-learn
On Thursday, 21 January 2016 at 14:36:36 UTC, Rikki Cattermole wrote: On 22/01/16 3:07 AM, W.J. wrote: On Thursday, 21 January 2016 at 13:15:46 UTC, Rikki Cattermole wrote: [...] Thanks for your reply. So writeln consumes the values in an InputRange. That leads me to believe that if I feed

Re: Speed of csvReader

2016-01-21 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 21 January 2016 at 15:17:08 UTC, data pulverizer wrote: On Thursday, 21 January 2016 at 14:56:13 UTC, Saurabh Das wrote: @Edwin van Leeuwen The csvReader is what takes the most time, the readText takes 0.229 s The underlying problem most likely is that csvReader has (AFAIK) never

Re: Speed of csvReader

2016-01-21 Thread bachmeier via Digitalmars-d-learn
On Thursday, 21 January 2016 at 10:48:15 UTC, data pulverizer wrote: Running Ubuntu 14.04 LTS In that case, have you looked at http://lancebachmeier.com/rdlang/ If this is a serious bottleneck you can solve it with two lines evalRQ(`x <- fread("Acquisition_2009Q2.txt", sep = "|", colClass

Re: Speed of csvReader

2016-01-21 Thread bachmeier via Digitalmars-d-learn
On Thursday, 21 January 2016 at 11:08:18 UTC, Ali Çehreli wrote: We should understand why D is slow in this case. :) Ali fread source is here: https://github.com/Rdatatable/data.table/blob/master/src/fread.c Good luck trying to work through that (which explains why I'm using D). I don't kn

Linking C libraries with DMD

2016-01-21 Thread jmh530 via Digitalmars-d-learn
I'm trying to understand calling C libraries from D on Windows with DMD. I made a simple example and compiled it with a static library fine (so I've converted the .h file correctly). Then, I compiled with gcc to a shared library (because I cannot for the life of me figure out how to do this wit

Re: Speed of csvReader

2016-01-21 Thread wobbles via Digitalmars-d-learn
On Thursday, 21 January 2016 at 15:17:08 UTC, data pulverizer wrote: On Thursday, 21 January 2016 at 14:56:13 UTC, Saurabh Das wrote: On Thursday, 21 January 2016 at 14:32:52 UTC, Saurabh Das wrote: [...] Actually since you're aiming for speed, this might be better: sw.start(); auto records

Re: Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 January 2016 at 14:56:13 UTC, Saurabh Das wrote: On Thursday, 21 January 2016 at 14:32:52 UTC, Saurabh Das wrote: On Thursday, 21 January 2016 at 13:42:11 UTC, Edwin van Leeuwen wrote: On Thursday, 21 January 2016 at 09:39:30 UTC, data pulverizer wrote: StopWatch sw; sw.sta

Re: Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 January 2016 at 15:17:08 UTC, data pulverizer wrote: On Thursday, 21 January 2016 at 14:56:13 UTC, Saurabh Das wrote: On Thursday, 21 January 2016 at 14:32:52 UTC, Saurabh Das Actually since you're aiming for speed, this might be better: sw.start(); auto records = File("Acquis

Re: Is this a feature?

2016-01-21 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 21 January 2016 at 14:39:43 UTC, Adam D. Ruppe wrote: On Thursday, 21 January 2016 at 14:35:09 UTC, Sebastiaan Koppe wrote: static if (!is(SomethingUndefined!moreUndefined[0] : UndefinedThing)) Yes, the is expression returns false for undefined things because they aren't types.

Re: Speed of csvReader

2016-01-21 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 21 January 2016 at 14:32:52 UTC, Saurabh Das wrote: On Thursday, 21 January 2016 at 13:42:11 UTC, Edwin van Leeuwen wrote: On Thursday, 21 January 2016 at 09:39:30 UTC, data pulverizer wrote: StopWatch sw; sw.start(); auto buffer = std.file.readText("Acquisition_2009Q2.txt");

  1   2   >