Re: How do i activate the latest nightly without knowing the date ?

2018-01-04 Thread user789 via Digitalmars-d-learn
On Thursday, 4 January 2018 at 20:37:16 UTC, user789 wrote: On Thursday, 4 January 2018 at 20:28:47 UTC, user789 wrote: After using the script to setup DMD nightly i read in the output that i have to run "source ~/dlang/dmd-master-2018-01-04/activate" to have DMD DUB etc working. Is there

Re: How do you do "const nazi" in D?

2018-01-04 Thread Dukc via Digitalmars-d-learn
On Thursday, 4 January 2018 at 13:52:14 UTC, Mark wrote: You ma find Ali Cehreli's talk from DConf 2013 [1] useful. It includes some guidelines (basically recommendations) on how to use immutable and const. Same topic and same mentor here, but in text form:

Any free stock market data API?

2018-01-04 Thread Amorphorious via Digitalmars-d-learn
Most are in other languages: https://www.alphavantage.co/ https://iextrading.com/ are two free ones. I'm just hoping for a more D'ish solution.

Re: Any free stock market data API?

2018-01-04 Thread Amorphorious via Digitalmars-d-learn
On Thursday, 4 January 2018 at 23:04:44 UTC, Amorphorious wrote: Most are in other languages: https://www.alphavantage.co/ https://iextrading.com/ are two free ones. I'm just hoping for a more D'ish solution. http://www.quantmod.com/ I'm wondering if I can use something like alphavantage

How do i activate the latest nightly without knowing the date ?

2018-01-04 Thread user789 via Digitalmars-d-learn
After using the script to setup DMD nightly i read in the output that i have to run "source ~/dlang/dmd-master-2018-01-04/activate" to have DMD DUB etc working. Is there another activation command, working without the date, suitable for a cron job ?

Re: Passing a type as paramter to super

2018-01-04 Thread Marc via Digitalmars-d-learn
On Thursday, 4 January 2018 at 19:16:03 UTC, Marc wrote: For code generation purposes, I'd like to pass a type name to base class. I'm not sure if it's supported, I didn't find anything at documentation for class constructor but it does compile: class A { static {

Re: how do I get only static member of a class?

2018-01-04 Thread Marc via Digitalmars-d-learn
On Thursday, 4 January 2018 at 00:02:24 UTC, Ali Çehreli wrote: On 01/03/2018 03:48 PM, Marc wrote: I found no way with __traits() on std.traits. I found isStaticFunction and isStaticArray but nothing about a member. Is this by desgin? Give a class like: class C { static int a, b, c; int

Re: Error: variable i cannot be read at compile time

2018-01-04 Thread Ali Çehreli via Digitalmars-d-learn
On 01/04/2018 08:51 AM, Vino wrote: > auto read () { [...] > return tuple(Ucol1, Ucol2, Ucol3, rSize); > } read() returns a tuple of values of different types. > for(int i = 0; i < Size; i++) { > typeof(read()[i]) Datacol; typeof is a compile-time expression but there cannot be a consistent

Passing a type as paramter to super

2018-01-04 Thread Marc via Digitalmars-d-learn
For code generation purposes, I'd like to pass a type name to base class. I'm not sure if it's supported, I didn't find anything at documentation for class constructor but it does compile: class A { static { int a, b; } this(T)() { } } then

Re: Help optimizing UnCompress for gzipped files

2018-01-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/4/18 1:57 PM, Christian Köstlin wrote: Sorry, but I do not get how to cleanup the mallocated memory :) Could you help me out here? free(mypipe.window.ptr); At the moment this works because you haven't released any data from the front. But eventually, I will need to figure out how to

Re: Help optimizing UnCompress for gzipped files

2018-01-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/4/18 1:57 PM, Christian Köstlin wrote: Thanks Steve, this runs now faster, I will update the table. Still a bit irked that I can't match the C speed :/ But, I can't get your C speed to duplicate on my mac even with gcc, so I'm not sure where to start. I find it interesting that you are

Re: How do i activate the latest nightly without knowing the date ?

2018-01-04 Thread user789 via Digitalmars-d-learn
On Thursday, 4 January 2018 at 20:28:47 UTC, user789 wrote: After using the script to setup DMD nightly i read in the output that i have to run "source ~/dlang/dmd-master-2018-01-04/activate" to have DMD DUB etc working. Is there another activation command, working without the date, suitable

Re: Passing a type as paramter to super

2018-01-04 Thread Ali Çehreli via Digitalmars-d-learn
On 01/04/2018 11:16 AM, Marc wrote: For code generation purposes, I'd like to pass a type name to base class. I'm not sure if it's supported, I didn't find anything at documentation for class constructor but it does compile: class A { static {     int a, b; } this(T)() {    

Re: Help optimizing UnCompress for gzipped files

2018-01-04 Thread Christian Köstlin via Digitalmars-d-learn
On 04.01.18 16:53, Steven Schveighoffer wrote: > On 1/3/18 3:28 PM, Steven Schveighoffer wrote: > >> Stay tuned, there will be updates to iopipe to hopefully make it as >> fast in this microbenchmark as the C version :) > > v0.0.3 has been released. To take advantage of using malloc/realloc, you

Re: Dub and libraries

2018-01-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 04, 2018 19:05:59 Russel Winder via Digitalmars-d-learn wrote: > Is it the case that, for library things on the Dub repository, Dub will > only create library archives, .a, that it is unable to create shared > objects and DLLs? Well, you can configure a dub project to be a

Re: Passing a type as paramter to super

2018-01-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/4/18 2:19 PM, Marc wrote: On Thursday, 4 January 2018 at 19:16:03 UTC, Marc wrote: For code generation purposes, I'd like to pass a type name to base class. I'm not sure if it's supported, I didn't find anything at documentation for class constructor but it does compile: class A {

Re: What could this OptLink Error mean?

2018-01-04 Thread Dukc via Digitalmars-d-learn
On Saturday, 30 December 2017 at 00:49:48 UTC, user1234 wrote: The deps have to be rebuild too. After downloading dmd 78, it started to work. It's likely you were right about the issue, DUB rebuilt everything after detecting new compiler version. Sorry for my late reply.

Dub and libraries

2018-01-04 Thread Russel Winder via Digitalmars-d-learn
Is it the case that, for library things on the Dub repository, Dub will only create library archives, .a, that it is unable to create shared objects and DLLs? -- Russel. == Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Roadm: +44 7770 465 077

Re: Consequences of casting away immutable from pointers

2018-01-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/4/18 10:58 PM, jmh530 wrote: I'm trying to understand the consequences of casting away immutable from a pointer. The code below has some weird things going on like the pointers still point to the correct address but when you dereference them they don't point to the correct value anymore.

Re: Any free stock market data API?

2018-01-04 Thread Laeeth Isharc via Digitalmars-d-learn
On Thursday, 4 January 2018 at 23:04:44 UTC, Amorphorious wrote: Most are in other languages: https://www.alphavantage.co/ https://iextrading.com/ are two free ones. I'm just hoping for a more D'ish solution. I wrote a simple api for quandl.com and somewhere I have one for yahoo. Neither

Re: Any free stock market data API?

2018-01-04 Thread jmh530 via Digitalmars-d-learn
On Friday, 5 January 2018 at 01:45:46 UTC, Laeeth Isharc wrote: On Thursday, 4 January 2018 at 23:04:44 UTC, Amorphorious wrote: Most are in other languages: https://www.alphavantage.co/ https://iextrading.com/ are two free ones. I'm just hoping for a more D'ish solution. I wrote a simple

Re: Consequences of casting away immutable from pointers

2018-01-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 5 January 2018 at 04:10:54 UTC, Steven Schveighoffer wrote: The compiler assumes x is going to be 5 forever, so instead of loading the value at that address, it just loads 5 into a register (or maybe it just folds x == 5 into true). I was curious what dmd did, and the disassembly

Consequences of casting away immutable from pointers

2018-01-04 Thread jmh530 via Digitalmars-d-learn
I'm trying to understand the consequences of casting away immutable from a pointer. The code below has some weird things going on like the pointers still point to the correct address but when you dereference them they don't point to the correct value anymore. Should I just assume this is

Re: Consequences of casting away immutable from pointers

2018-01-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 04, 2018 23:10:54 Steven Schveighoffer via Digitalmars- d-learn wrote: > On 1/4/18 10:58 PM, jmh530 wrote: > > I'm trying to understand the consequences of casting away immutable from > > a pointer. The code below has some weird things going on like the > > pointers still

Re: Help optimizing UnCompress for gzipped files

2018-01-04 Thread Christian Köstlin via Digitalmars-d-learn
On 04.01.18 20:46, Steven Schveighoffer wrote: > On 1/4/18 1:57 PM, Christian Köstlin wrote: >> Thanks Steve, >> this runs now faster, I will update the table. > > Still a bit irked that I can't match the C speed :/ > > But, I can't get your C speed to duplicate on my mac even with gcc, so > I'm

I want to transmit the class name and the member name in the method

2018-01-04 Thread Brian via Digitalmars-d-learn
I think code style like: ~~ struct User { int id; string name; string email; } class ORM { } auto db = new ORM; auto users = db.select(User).where(email.like("*@hotmail.com")).limit(10); foreach(user; users) {

Re: Help optimizing UnCompress for gzipped files

2018-01-04 Thread Christian Köstlin via Digitalmars-d-learn
I added now a c variant, that does always malloc/memcpy/free. Its much slower for sure. Also I put some output in thats shows when a real realloc happens. Its like you said: did a real realloc did a real realloc did a real realloc did a real realloc did a real realloc did a real realloc did not a

Re: how to localize console and GUI apps in Windows

2018-01-04 Thread Andrei via Digitalmars-d-learn
On Friday, 29 December 2017 at 18:13:04 UTC, H. S. Teoh wrote: On Fri, Dec 29, 2017 at 10:35:53AM +, Andrei via Digitalmars-d-learn wrote: This may be endurable if you write an application where Russian is only one of rare options, and what if your whole environment is totally Russian?

Re: No modification of pointer values in safe functions?

2018-01-04 Thread Mark via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 23:49:33 UTC, H. S. Teoh wrote: On Wed, Jan 03, 2018 at 03:42:07PM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: On Wednesday, January 03, 2018 22:25:16 Mark via Digitalmars-d-learn wrote: [...] > https://dlang.org/spec/function.html#safe-functions > >

Re: Using iopipe to stream a gzipped file

2018-01-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/4/18 7:23 AM, Andrew wrote: On Thursday, 4 January 2018 at 12:15:27 UTC, Steven Schveighoffer wrote: In any case, I'll figure out how to deal with concatenated gzip file, and update iopipe. Next version will focus on a bunch of stuff relating to the 2 zip threads recently posted here.

Re: Single type of a tuple return type function

2018-01-04 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 4 January 2018 at 15:50:35 UTC, Vino wrote: Hi All, Request your help, on how o find the single type of a tuple return type function, eg, auto Fn (){ Array!string a; Array!int b; Array!ulong c; return tuple(a, b, c); } if we use "ReturnType!Fn" it gives us the output as

Re: Help optimizing UnCompress for gzipped files

2018-01-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/3/18 3:28 PM, Steven Schveighoffer wrote: Stay tuned, there will be updates to iopipe to hopefully make it as fast in this microbenchmark as the C version :) v0.0.3 has been released. To take advantage of using malloc/realloc, you can use std.experimental.allocator.mallocator.Mallocator

Single type of a tuple return type function

2018-01-04 Thread Vino via Digitalmars-d-learn
Hi All, Request your help, on how o find the single type of a tuple return type function, eg, auto Fn (){ Array!string a; Array!int b; Array!ulong c; return tuple(a, b, c); } if we use "ReturnType!Fn" it gives us the output as (Array!string,Array!int, Array!ulong) but what is need is the

Re: Single type of a tuple return type function

2018-01-04 Thread Vino via Digitalmars-d-learn
On Thursday, 4 January 2018 at 16:09:07 UTC, Simen Kjærås wrote: On Thursday, 4 January 2018 at 15:50:35 UTC, Vino wrote: [...] ReturnType!Fn[0] tries to give you the 0th field of the tuple, but as the error message indicates, you can't do that without an instance. What you want is the

Error: variable i cannot be read at compile time

2018-01-04 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on the below error for the below program. Error: CReadCol.d(20): Error: variable i cannot be read at compile time CReadCol.d(21): Error: variable i cannot be read at compile time CReadCol.d(22): Error: variable i cannot be read at compile time Program import

Re: Using iopipe to stream a gzipped file

2018-01-04 Thread Andrew via Digitalmars-d-learn
On Thursday, 4 January 2018 at 15:48:21 UTC, Steven Schveighoffer wrote: It's now been updated, see version 0.0.3. Note, the performance isn't something I focused on. I'll note that gzcat | wc -l is 2x faster than your simple example on that file. I can think of a couple reasons for this:

Re: Consequences of casting away immutable from pointers

2018-01-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 05, 2018 04:16:48 Adam D. Ruppe via Digitalmars-d-learn wrote: > On Friday, 5 January 2018 at 04:10:54 UTC, Steven Schveighoffer > > wrote: > > The compiler assumes x is going to be 5 forever, so instead of > > loading the value at that address, it just loads 5 into a > >

Error: variable foo conflicts with struct foo

2018-01-04 Thread Stijn via Digitalmars-d-learn
Why is it not allowed for a variable name to match a type name? The following example fails with "Error: variable foo conflicts with struct foo" struct foo {} foo foo;

Re: Error: variable foo conflicts with struct foo

2018-01-04 Thread Colin via Digitalmars-d-learn
On Thursday, 4 January 2018 at 17:45:35 UTC, Stijn wrote: Why is it not allowed for a variable name to match a type name? The following example fails with "Error: variable foo conflicts with struct foo" struct foo {} foo foo; How can the compiler know which symbol is which symbol if

Re: Error: variable foo conflicts with struct foo

2018-01-04 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 4 January 2018 at 17:45:35 UTC, Stijn wrote: Why is it not allowed for a variable name to match a type name? The following example fails with "Error: variable foo conflicts with struct foo" struct foo {} foo foo; Imagine if you then tried to write something like

Re: Error: variable foo conflicts with struct foo

2018-01-04 Thread Stijn via Digitalmars-d-learn
On Thursday, 4 January 2018 at 17:59:55 UTC, Colin wrote: How can the compiler know which symbol is which symbol if everything has the same name? Standard practice is to capitalise type names and camelCase variable names. The C# compiler has no trouble understanding code like that, so I

Re: Gc/D_runtime prevents dangling pointers?

2018-01-04 Thread tipdbmp via Digitalmars-d-learn
What is your definition of a dangling pointer? A pointer pointing to freed memory, which presumably '[0]' should be because it reallocates. It seems that the '~=' operator "knows" that there's a reference to 'a's old memory and it keeps it around instead of freeing it. I just don't

Re: Help optimizing UnCompress for gzipped files

2018-01-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/4/18 4:47 AM, Christian Köstlin wrote: I added now a c variant, that does always malloc/memcpy/free. Its much slower for sure. Also I put some output in thats shows when a real realloc happens. Its like you said: did a real realloc did a real realloc did a real realloc did a real realloc

Re: How do you do "const nazi" in D?

2018-01-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/3/18 12:27 PM, Marc wrote: for a safe programming, since C/C++ times I try to make thing const as possible. locals, parameters etc anything which isn't going to change. How do you do that in D? immutable everywhere? For parameters, I'd recommend const, not immutable, as const allows more

Re: Gc/D_runtime prevents dangling pointers?

2018-01-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/4/18 6:50 AM, thedeemon wrote: On Thursday, 4 January 2018 at 11:05:25 UTC, tipdbmp wrote: It seems that the '~=' operator "knows" that there's a reference to 'a's old memory and it keeps it around instead of freeing it. It's just not its job to free that memory. That memory is freed

Re: Using iopipe to stream a gzipped file

2018-01-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/4/18 7:01 AM, Andrew wrote: Ah thank you, that makes sense. These types of files are compressed using the bgzip utility so that the file can be indexed meaning specific rows extracted quickly (there's more details of this here http://www.htslib.org/doc/tabix.html and the code can be

Re: Using iopipe to stream a gzipped file

2018-01-04 Thread Andrew via Digitalmars-d-learn
On Thursday, 4 January 2018 at 12:15:27 UTC, Steven Schveighoffer wrote: On 1/4/18 7:01 AM, Andrew wrote: Ah thank you, that makes sense. These types of files are compressed using the bgzip utility so that the file can be indexed meaning specific rows extracted quickly (there's more details

Re: Gc/D_runtime prevents dangling pointers?

2018-01-04 Thread thedeemon via Digitalmars-d-learn
On Thursday, 4 January 2018 at 11:05:25 UTC, tipdbmp wrote: What is your definition of a dangling pointer? A pointer pointing to freed memory, which presumably '[0]' should be because it reallocates. It allocates a larger array, but the old version is not freed up front. Right because there

Re: Using iopipe to stream a gzipped file

2018-01-04 Thread Andrew via Digitalmars-d-learn
On Thursday, 4 January 2018 at 02:44:09 UTC, Steven Schveighoffer wrote: On 1/3/18 12:03 PM, Andrew wrote: Thanks for looking into this. So it looks like the file you have is a concatenated gzip file. If I gunzip the file and recompress it, it works properly. Looking at the docs of zlib

Re: how to localize console and GUI apps in Windows

2018-01-04 Thread Andrei via Digitalmars-d-learn
On Friday, 29 December 2017 at 18:13:04 UTC, H. S. Teoh wrote: If the problem is in readln(), then you probably need to read the input in binary (i.e., as ubyte[]) and convert it manually. Could you kindly explain how I can read console input into binary ubyte[]?

Re: How do you do "const nazi" in D?

2018-01-04 Thread Mark via Digitalmars-d-learn
On Wednesday, 3 January 2018 at 17:27:38 UTC, Marc wrote: for a safe programming, since C/C++ times I try to make thing const as possible. locals, parameters etc anything which isn't going to change. How do you do that in D? immutable everywhere? for example: foreach(Field field;