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

Re: writeln wipes contents of variables ?

2016-01-21 Thread Rikki Cattermole via Digitalmars-d-learn
On 22/01/16 2:11 AM, W.J. wrote: Hi everybody! I'm new to D and trying to wrap my head around ranges. For a start I'm trying to take a input string and transform it, group it, etc. After each step I inspect the result. It works fine until step 3 where all of a sudden, after write(ln)ing the

Re: writeln wipes contents of variables ?

2016-01-21 Thread W.J. via Digitalmars-d-learn
On Thursday, 21 January 2016 at 13:15:46 UTC, Rikki Cattermole wrote: Ok so input ranges. An input range is a little bit like an iterator (if you know what that is). When an input range has been read fully, it is empty aka no longer has any values associated with it. writeln, reads an

Re: Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 January 2016 at 10:40:39 UTC, data pulverizer wrote: On Thursday, 21 January 2016 at 10:20:12 UTC, Rikki Cattermole wrote: Okay without registering not gonna get that data. So usual things to think about, did you turn on release mode? What about inlining? Lastly how about

Re: Distribution of D apps

2016-01-21 Thread W.J. via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 16:01:11 UTC, Dibyendu Majumdar wrote: Hi, I am trying to understand the options for distributing a D app to users. My assumption is that only the shared libraries and binaries need to be distributed, and I need to include the D libraries. Is this correct?

Re: Speed of csvReader

2016-01-21 Thread Edwin van Leeuwen via Digitalmars-d-learn
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"); auto records = csvReader!row_type(buffer, '|').array; sw.stop(); Is it csvReader or readText that is slow? i.e. could you move

Re: Distribution of D apps

2016-01-21 Thread FreeSlave via Digitalmars-d-learn
On Thursday, 21 January 2016 at 13:26:15 UTC, W.J. wrote: On Wednesday, 20 January 2016 at 16:01:11 UTC, Dibyendu Majumdar wrote: Hi, I am trying to understand the options for distributing a D app to users. My assumption is that only the shared libraries and binaries need to be distributed,

Re: Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 January 2016 at 11:08:18 UTC, Ali Çehreli wrote: On 01/21/2016 02:40 AM, data pulverizer wrote: dmd -release -inline code.d These two as well please: -O -boundscheck=off the ingest of files and speed of calculation is very important to me. We should understand why D is

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

Re: Speed of csvReader

2016-01-21 Thread Ali Çehreli via Digitalmars-d-learn
On 01/21/2016 02:40 AM, data pulverizer wrote: dmd -release -inline code.d These two as well please: -O -boundscheck=off the ingest of files and speed of calculation is very important to me. We should understand why D is slow in this case. :) Ali

writeln wipes contents of variables ?

2016-01-21 Thread W.J. via Digitalmars-d-learn
Hi everybody! I'm new to D and trying to wrap my head around ranges. For a start I'm trying to take a input string and transform it, group it, etc. After each step I inspect the result. It works fine until step 3 where all of a sudden, after write(ln)ing the result, "step3" holds an array of

Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
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. Here I am reading Fannie Mae mortgage acquisition data which can be found here

Re: Speed of csvReader

2016-01-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 January 2016 at 10:20:12 UTC, Rikki Cattermole wrote: Okay without registering not gonna get that data. So usual things to think about, did you turn on release mode? What about inlining? Lastly how about disabling the GC? import core.memory : GC; GC.disable(); dmd -release

Re: Speed of csvReader

2016-01-21 Thread Rikki Cattermole via Digitalmars-d-learn
On 21/01/16 10:39 PM, 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. Here I am reading Fannie Mae mortgage acquisition data which can be found here

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 =

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 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;

Re: Distribution of D apps

2016-01-21 Thread W.J. via Digitalmars-d-learn
On Thursday, 21 January 2016 at 14:03:03 UTC, FreeSlave wrote: On Thursday, 21 January 2016 at 13:26:15 UTC, W.J. wrote: On Wednesday, 20 January 2016 at 16:01:11 UTC, Dibyendu Majumdar wrote: [...] Hi, On Linux you can use 'ldd' to print shared library dependencies. On Windows you can

Re: Speed of csvReader

2016-01-21 Thread Saurabh Das via Digitalmars-d-learn
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"); auto records = csvReader!row_type(buffer, '|').array;

Is this a feature?

2016-01-21 Thread Sebastiaan Koppe via Digitalmars-d-learn
module undefined; unittest { static if (!is(SomethingUndefined!moreUndefined[0] : UndefinedThing)) { pragma(msg,"This will compile just fine!"); } }

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 =

Re: writeln wipes contents of variables ?

2016-01-21 Thread Rikki Cattermole via Digitalmars-d-learn
On 22/01/16 3:07 AM, W.J. wrote: On Thursday, 21 January 2016 at 13:15:46 UTC, Rikki Cattermole wrote: Ok so input ranges. An input range is a little bit like an iterator (if you know what that is). When an input range has been read fully, it is empty aka no longer has any values associated

Re: Is this a feature?

2016-01-21 Thread Adam D. Ruppe via Digitalmars-d-learn
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. The standard library uses this in a lot of places to test for

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:

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

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

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

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: 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:

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)

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

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: 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

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 = "|",

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)

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

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

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 -

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

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:

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

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

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

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: 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, >

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 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: 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

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

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

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

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

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

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 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 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: 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 (

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

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

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

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

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

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: 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

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

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

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

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

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,

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: 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

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

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

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

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

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.

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

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 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

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: 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:

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 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

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

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 >

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: 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 > >

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

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.

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: 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

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

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

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 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

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: 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

  1   2   >