Re: BigFloat?

2017-04-10 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2017-04-10 at 12:17 -0700, H. S. Teoh via Digitalmars-d-learn wrote: > […] > > There is no BigFloat in phobos, you could try looking at > code.dlang.org > to see if there's anything that you could use. > […] Isn't the way forward here just to wrap GMP:

Dub and compilation

2017-04-10 Thread Russel Winder via Digitalmars-d-learn
As I understand it, Dub compiles a downloaded dependency into the local Dub cache. This means you cannot store a debug build and a release build for multiple architectures and different compilers, at the same time, and you only get a .a file, no .so file. Cargo downloads source to the cache but

Dub, Git, Mercurial, Bazaar

2017-04-10 Thread Russel Winder via Digitalmars-d-learn
Go only uses Git, Mercurial, or Bazaar for dependency handling. Rust (via Cargo) allows for a central repository, and Git (, and Mercurial ?) repositories. Dub appears only to allow for central repository, or have I missed it's ability to work with DVCS repositories? If Dub cannot handle DVCS

Re: length = 0 clears reserve

2017-04-10 Thread Jon Degenhardt via Digitalmars-d-learn
On Tuesday, 11 April 2017 at 01:59:57 UTC, Jonathan M Davis wrote: On Tuesday, April 11, 2017 01:42:32 Jethro via Digitalmars-d-learn wrote: arrays have the ability to reserve but when setting the length to 0, it removes the reserve!! ;/ char[] buf; buf.reserve = 1000; buf.length = 0;

Re: ctfe append too slow, but can't speed up

2017-04-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 11 April 2017 at 02:20:37 UTC, Jethro wrote: I need a drop in replacement(no other changes) that can take over the duties of string and allow for memory reuse. There is no memory reuse in CTFE right now, that's why the engine is being rewritten... I'd suggest writing a regular

ctfe append too slow, but can't speed up

2017-04-10 Thread Jethro via Digitalmars-d-learn
ctfe string appending is way to slow, I have tried the suggested methods and nothing works and slows down by at least an order of magnitude. I need a drop in replacement(no other changes) that can take over the duties of string and allow for memory reuse. reserve, cpacity, assumeSafeAppend

Re: Forwarding calls to objects of another type

2017-04-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 10 April 2017 at 21:27:34 UTC, Basile B. wrote: 2) This is about the reduce templates. As I've commented, I can't use a template lambda with reduce, but I can use a lambda taking ints as arguments. Why is this? The error message I get when using the template lambda is: "template

Re: Tell compiler not to try and CTFE template?

2017-04-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 11, 2017 01:53:07 Jethro via Digitalmars-d-learn wrote: > I have a template that that takes no arguments. It takes a while > to compile, but if I simply create a dummy argument, D compiles > much quicker. > > e.g., > > void foo(string s)(); // slow, > > void foo(string s)(int x);

Re: length = 0 clears reserve

2017-04-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 11, 2017 01:42:32 Jethro via Digitalmars-d-learn wrote: > arrays have the ability to reserve but when setting the length to > 0, it removes the reserve!! ;/ > > char[] buf; > buf.reserve = 1000; > buf.length = 0; > assert(buf.capacity == 0); > > But I simply want to clear the

Tell compiler not to try and CTFE template?

2017-04-10 Thread Jethro via Digitalmars-d-learn
I have a template that that takes no arguments. It takes a while to compile, but if I simply create a dummy argument, D compiles much quicker. e.g., void foo(string s)(); // slow, void foo(string s)(int x); // fast. (I, of course, pass a dummy value for x) This is because the compiler

length = 0 clears reserve

2017-04-10 Thread Jethro via Digitalmars-d-learn
arrays have the ability to reserve but when setting the length to 0, it removes the reserve!! ;/ char[] buf; buf.reserve = 1000; buf.length = 0; assert(buf.capacity == 0); But I simply want to clear the buffer, not change it's reserve/capacity. I've tried to hack by setting the length to 0

Re: Forwarding calls to objects of another type

2017-04-10 Thread Basile B. via Digitalmars-d-learn
On Monday, 10 April 2017 at 21:04:10 UTC, Johan Fjeldtvedt wrote: I have a couple of questions related to the following code: https://gist.github.com/Jaffe-/b027287a884fc2e173a65601ec242676 1) This is a very simplified example, but what I'm trying to do here is to call `foo` on each object in

Re: std.socket classes

2017-04-10 Thread David Nadlinger via Digitalmars-d-learn
On Sunday, 9 April 2017 at 14:47:39 UTC, Jonathan Marler wrote: My guess is that making Socket a class prevents socket handle leaks because you can clean up the handle in the destructor when the memory gets freed if no one closes it. Is this the reason it is a class and are there any other

Forwarding calls to objects of another type

2017-04-10 Thread Johan Fjeldtvedt via Digitalmars-d-learn
I have a couple of questions related to the following code: https://gist.github.com/Jaffe-/b027287a884fc2e173a65601ec242676 1) This is a very simplified example, but what I'm trying to do here is to call `foo` on each object in `Container.ss` contains when `foo` is called, and likewise for

Re: std.socket classes

2017-04-10 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 10 April 2017 at 18:57:13 UTC, Adam D. Ruppe wrote: On Monday, 10 April 2017 at 16:18:20 UTC, Jonathan Marler wrote: An interesting benefit. However, I don't think this is the ideal way to support such a use case. If I was doing it myself, I'd probably do an interface / final

Re: BigFloat?

2017-04-10 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Apr 10, 2017 at 06:54:54PM +, Geroge Little via Digitalmars-d-learn wrote: > Is there support for BigFloat in phobos or any other package? I was > playing around with D and wrote some code that calculates a Fibonacci > sequence (iterative) with overflow detection that upgrades ulong

Re: Test if a class is extern(c++)

2017-04-10 Thread Benjamin Thaut via Digitalmars-d-learn
On Monday, 10 April 2017 at 18:56:42 UTC, BBasile wrote: Hello, I have a trait for this: https://github.com/BBasile/iz/blob/master/import/iz/types.d#L650 Hi BBasile, I think your trait is a good starting point for my needs. Thanks.

Re: std.socket classes

2017-04-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 10 April 2017 at 16:18:20 UTC, Jonathan Marler wrote: An interesting benefit. However, I don't think this is the ideal way to support such a use case. If I was doing it myself, I'd probably do an interface / final class split too (which also opens up a wee bit of additional easy

Re: Test if a class is extern(c++)

2017-04-10 Thread BBasile via Digitalmars-d-learn
On Monday, 10 April 2017 at 18:32:05 UTC, Benjamin Thaut wrote: In particular I want to know if the vtable of the class has the class info member. Is there any way to do this at compile time? At runtime? Kind Regards Benjamin Thaut Hello, I have a trait for this:

BigFloat?

2017-04-10 Thread Geroge Little via Digitalmars-d-learn
Is there support for BigFloat in phobos or any other package? I was playing around with D and wrote some code that calculates a Fibonacci sequence (iterative) with overflow detection that upgrades ulong to BigInt. I also wanted to use Binet's formula which requires sqrt(5) but it only works up

Test if a class is extern(c++)

2017-04-10 Thread Benjamin Thaut via Digitalmars-d-learn
In particular I want to know if the vtable of the class has the class info member. Is there any way to do this at compile time? At runtime? Kind Regards Benjamin Thaut

Re: I'm getting NAN out of nowhere

2017-04-10 Thread Binarydepth via Digitalmars-d-learn
On Monday, 13 July 2015 at 14:29:57 UTC, Steven Schveighoffer wrote: On 7/11/15 12:57 PM, flamencofantasy wrote: On Thursday, 9 July 2015 at 15:14:43 UTC, Binarydepth wrote: This is my code : import std.stdio : writeln, readf; void main(){ int[3] nums; float prom; foreach(nem;

Re: I'm getting NAN out of nowhere

2017-04-10 Thread Binarydepth via Digitalmars-d-learn
On Saturday, 11 July 2015 at 16:57:55 UTC, flamencofantasy wrote: On Thursday, 9 July 2015 at 15:14:43 UTC, Binarydepth wrote: This is my code : import std.stdio : writeln, readf; void main() { int[3] nums; float prom; foreach(nem; 0..2) {

Re: Testing D codes

2017-04-10 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2017-04-07 at 11:40 +0300, drug via Digitalmars-d-learn wrote: > […] > I do this. I have unittests in the module sources and have a > separate  > subpackage intended for more advanced testing only. Do you have an example project I could take a look at? -- Russel.

Re: std.socket classes

2017-04-10 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 10 April 2017 at 04:32:20 UTC, Adam D. Ruppe wrote: On Sunday, 9 April 2017 at 14:47:39 UTC, Jonathan Marler wrote: Does anyone know why Socket and Address in phobos were created as classes instead of structs? It is probably just the historical evolution, but I find it pretty

Re: BinaryHeap crashes upon insertion if heapified with an array of length 1?

2017-04-10 Thread TheGag96 via Digitalmars-d-learn
On Sunday, 9 April 2017 at 13:31:05 UTC, Michael Coulombe wrote: This is a bug in the insert method. I created a bug report for you and submitted a pull request for a fix: https://issues.dlang.org/show_bug.cgi?id=17314 Ah, so it is. Thanks!!

Re: DUB mismatch between project structure and dub.json contents

2017-04-10 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 10 April 2017 at 12:56:49 UTC, Nordlöw wrote: src/knet/traversal.d(20,8): Error: module factixs from file src/knet/factixs.d must be imported with 'import factixs;' What am I doing wrong? My first guess would be that the module declaration in that file is incorrect. Are you sure

Re: DUB mismatch between project structure and dub.json contents

2017-04-10 Thread Nordlöw via Digitalmars-d-learn
On Monday, 10 April 2017 at 12:56:49 UTC, Nordlöw wrote: I have a project with the tree structure ├── knetquery Ignore this sub-directory. It's unused. Further, `dub -v` outputs Using dub registry url 'http://code.dlang.org/' Refreshing local packages (refresh existing: true)... Looking for

DUB mismatch between project structure and dub.json contents

2017-04-10 Thread Nordlöw via Digitalmars-d-learn
I have a project with the tree structure ├── knetquery └── src └── knet ├── lectures ├── readers └── tests ├── linenoise (submodule) ├── linenoise-d (submodule) │ ... └── phobos-next (submodule) ... and a DUB-conversion whoose `dub.json` currently contains {

URL (or URI) Pegged grammar - is it exists?

2017-04-10 Thread crimaniak via Digitalmars-d-learn
Hi, all! Yes, I know, most simple way to validate URL is regex and it works for most cases, but I search for a correct solution (ideally rfc3986-compatible), which will be hard to implement using regular expressions.