Re: version identifier hygiene

2017-01-16 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-01-16 21:04, Ali Çehreli wrote: It is plausible to compile and link the sources of multiple packages on the same command line at the same. (I'm not sure whether this is required for e.g. LLVM's link-time optimization (LTO) but I think it helps the compiler as well.) The trouble is, the

Re: Chain a range of ranges?

2017-01-16 Thread Brad Anderson via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 03:21:39 UTC, Yuxuan Shui wrote: The built in chain seems to only be able to chain a fixed number of ranges, is there a way to chain a range/array of ranges? See std.algorithm.iteration.joiner

Chain a range of ranges?

2017-01-16 Thread Yuxuan Shui via Digitalmars-d-learn
The built in chain seems to only be able to chain a fixed number of ranges, is there a way to chain a range/array of ranges?

Re: Initializing floating point types with explicit mantisa and exponent

2017-01-16 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 00:08:24 UTC, Nordlöw wrote: How do I best initialize a D double to an exact mantissa and exponent representation? I'm specifically interested in 2^^i for all i in [min_exp, max_exp] See std.bitmanip : FloatRep , DoubleRep;

Re: Initializing floating point types with explicit mantisa and exponent

2017-01-16 Thread pineapple via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 00:08:24 UTC, Nordlöw wrote: How do I best initialize a D double to an exact mantissa and exponent representation? I'm specifically interested in 2^^i for all i in [min_exp, max_exp] This mach module can do the job:

Initializing floating point types with explicit mantisa and exponent

2017-01-16 Thread Nordlöw via Digitalmars-d-learn
How do I best initialize a D double to an exact mantissa and exponent representation? I'm specifically interested in 2^^i for all i in [min_exp, max_exp]

Re: Thread will get garbage collected?

2017-01-16 Thread kinke via Digitalmars-d-learn
On Monday, 16 January 2017 at 22:08:56 UTC, JN wrote: Am I correctly understanding, that after going out of scope, it's possible for GC to destroy my thread before the file finishes loading? How to prevent GC from destroying my thread before it finishes and make sure the file is loaded

Thread will get garbage collected?

2017-01-16 Thread JN via Digitalmars-d-learn
I'm looking at the example code for core.thread Thread class: new Thread({ // Codes to run in the newly created thread. }).start(); let's imagine I put the code in a function: void loadFileAsync(string path) { new Thread({ writeln(readText(path));// imagine the file is

version identifier hygiene

2017-01-16 Thread Ali Çehreli via Digitalmars-d-learn
It is plausible to compile and link the sources of multiple packages on the same command line at the same. (I'm not sure whether this is required for e.g. LLVM's link-time optimization (LTO) but I think it helps the compiler as well.) The trouble is, the version identifiers used by one

Re: Using Dub

2017-01-16 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2017-01-16 at 16:47 +, cym13 via Digitalmars-d-learn wrote: > […] > > What do you mean it failed? I did that on another computer to  > test and it works flawlessly for me. > > […] trying a settings.sdl file failed setting.json works. -- Russel.

Re: Using Dub

2017-01-16 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2017-01-16 at 16:51 +, cym13 via Digitalmars-d-learn wrote: > […] > Oh, maybe you're on windows, in which case the settings.json file  > must be placed in either $ProgramData\dub or in $APPDATA\dub.  > Relevant lines of dub.d:  >

Re: Namespaces like C++

2017-01-16 Thread Andrey via Digitalmars-d-learn
On Monday, 16 January 2017 at 19:17:57 UTC, Mike Parker wrote: D namespaces generally follow the format [package names].moduleName.Type. So to have ui.Manager, then either the module, not the package, needs to be named 'ui', or you need to do the following: // file ui/package.d module ui;

Re: Namespaces like C++

2017-01-16 Thread Mike Parker via Digitalmars-d-learn
On Monday, 16 January 2017 at 18:02:09 UTC, Andrey wrote: Hello, can I using namespaces like in C++, for example: ui::Widget or ui::Manager? I created ui/widget.d and ui/manager.d for implementation classes Widget and Manager, bun I can't import their correctly for using ui.Manager uiManager;

Re: Referring to array element by descriptive name

2017-01-16 Thread albert-j via Digitalmars-d-learn
Thank you for all your answers. I was concerned because I'm dealing with a small function that is called many times and where the bulk of the calculations in the simulation takes place. So even 5% performance difference would be significant for me. But it is good to know that compilers are

Re: Namespaces like C++

2017-01-16 Thread rjframe via Digitalmars-d-learn
On Mon, 16 Jan 2017 18:02:09 +, Andrey wrote: > Hello, can I using namespaces like in C++, for example: ui::Widget or > ui::Manager? I created ui/widget.d and ui/manager.d for implementation > classes Widget and Manager, bun I can't import their correctly for using > ui.Manager uiManager; >

Namespaces like C++

2017-01-16 Thread Andrey via Digitalmars-d-learn
Hello, can I using namespaces like in C++, for example: ui::Widget or ui::Manager? I created ui/widget.d and ui/manager.d for implementation classes Widget and Manager, bun I can't import their correctly for using ui.Manager uiManager; If it is impossible, then what is the best way to using

Re: Is it ok to inherit multiple times same templated interface?

2017-01-16 Thread Meta via Digitalmars-d-learn
On Sunday, 15 January 2017 at 23:25:25 UTC, Ryan wrote: How would overloading work? Overload resolution works based on function/method parameters, not return types. In the example you gave the 3 get functions are indistinguishable. If the template parameter was used for a method parameter

Re: CMake support for D

2017-01-16 Thread King_DuckZ via Digitalmars-d-learn
On Monday, 16 January 2017 at 12:29:46 UTC, Russel Winder wrote: On Mon, 2017-01-16 at 11:40 +, King_DuckZ via Digitalmars-d-learn wrote: On Sunday, 3 January 2016 at 17:30:15 UTC, Dibyendu Majumdar wrote: > Does CMake recognise D in the enable_language command? > > If not is there a

Re: Changing template parameters

2017-01-16 Thread Dlearner via Digitalmars-d-learn
On Monday, 16 January 2017 at 16:08:07 UTC, Rene Zwanenburg wrote: On Monday, 16 January 2017 at 15:56:16 UTC, Jack Stouffer wrote: Same way you use any template parameters, auto i = uniform!("(]")(0, 1000); Also, if the template parameter consists of a single token you can omit the

Re: Using Dub

2017-01-16 Thread cym13 via Digitalmars-d-learn
On Monday, 16 January 2017 at 16:47:29 UTC, cym13 wrote: On Monday, 16 January 2017 at 10:59:33 UTC, Russel Winder wrote: On Mon, 2017-01-16 at 10:47 +, cym13 via Digitalmars-d-learn wrote: On Monday, 16 January 2017 at 09:42:03 UTC, Russel Winder wrote: > On Sun, 2017-01-15 at 17:44

Re: Using Dub

2017-01-16 Thread cym13 via Digitalmars-d-learn
On Monday, 16 January 2017 at 10:59:33 UTC, Russel Winder wrote: On Mon, 2017-01-16 at 10:47 +, cym13 via Digitalmars-d-learn wrote: On Monday, 16 January 2017 at 09:42:03 UTC, Russel Winder wrote: > On Sun, 2017-01-15 at 17:44 +, cym13 via > Digitalmars-d-learn wrote: > > On Sunday,

Re: Changing template parameters

2017-01-16 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 16 January 2017 at 15:56:16 UTC, Jack Stouffer wrote: Same way you use any template parameters, auto i = uniform!("(]")(0, 1000); Also, if the template parameter consists of a single token you can omit the parens: auto i = uniform!"(]"(0, 1000);

Re: Using Dub

2017-01-16 Thread Dejan Lekic via Digitalmars-d-learn
On Monday, 16 January 2017 at 09:40:55 UTC, Russel Winder wrote: On the one hand Cargo works wonderfully with Rust so I had hoped Dub would work wonderfully with D. Sadly I am finding it doesn't. Possibly my fault, but still annoying. Cargo does not have multiple Rust compilers as an option.

Re: Changing template parameters

2017-01-16 Thread Jack Stouffer via Digitalmars-d-learn
On Monday, 16 January 2017 at 15:32:33 UTC, Dlearner wrote: Hey, quick question! I'm messing around with std.random and noticed that you can change the boundaries parameter to be either open or closed intervals on either side. By default it is "[)". How do I change these template

Changing template parameters

2017-01-16 Thread Dlearner via Digitalmars-d-learn
Hey, quick question! I'm messing around with std.random and noticed that you can change the boundaries parameter to be either open or closed intervals on either side. By default it is "[)". How do I change these template parameters?

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-16 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 15 January 2017 at 19:48:04 UTC, Nestor wrote: I see. So correcting my original doubt: How could I parse an UTF16LE file line by line (producing a proper string in each iteration) without loading the entire file into memory? Could... roll your own? Although if you wanted it to be

Re: Quine using strings?

2017-01-16 Thread pineapple via Digitalmars-d-learn
On Monday, 16 January 2017 at 09:33:23 UTC, Nestor wrote: PS. Isn't this approach considered "cheating" in quines? ;) I'm afraid so - while the empty program has been technically accepted as being a quine (e.g. http://www.ioccc.org/1994/smr.hint) programs which use file io to read their own

Re: CMake support for D

2017-01-16 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2017-01-16 at 11:40 +, King_DuckZ via Digitalmars-d-learn wrote: > On Sunday, 3 January 2016 at 17:30:15 UTC, Dibyendu Majumdar  > wrote: > > Does CMake recognise D in the enable_language command? > > > > If not is there a workaround? > > > > Thanks and Regards > > Dibyendu > > One

Re: Using Dub

2017-01-16 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2017-01-16 at 10:47 +, cym13 via Digitalmars-d-learn wrote: > On Monday, 16 January 2017 at 09:42:03 UTC, Russel Winder wrote: > > On Sun, 2017-01-15 at 17:44 +, cym13 via  > > Digitalmars-d-learn wrote: > > > On Sunday, 15 January 2017 at 13:23:25 UTC, Russel Winder  > > > wrote:

Re: Using Dub

2017-01-16 Thread cym13 via Digitalmars-d-learn
On Monday, 16 January 2017 at 09:42:03 UTC, Russel Winder wrote: On Sun, 2017-01-15 at 17:44 +, cym13 via Digitalmars-d-learn wrote: On Sunday, 15 January 2017 at 13:23:25 UTC, Russel Winder wrote: > Is there any way of setting dub to default to ldc2 rather > than dmd as the compiler of

emplacing extern(C++) class

2017-01-16 Thread drug via Digitalmars-d-learn
I'm interfacing to C++ I using emplacing extern(C++) to malloc'ed memory like http://wiki.dlang.org/Memory_Management (see Explicit Class Instance Allocation) This code segfaulted with extern(C++) TestClass. I guess it's because extern(C++) class aren't rooted from Object so instead of

Re: Dub, SDL, and Subpackages

2017-01-16 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2017-01-16 at 23:16 +1300, rikki cattermole via Digitalmars-d- learn wrote: > […] > Change targetType to "library" and it should work. > It doesn't auto infer that it should be library since you have > overriden  > that ability of it. That isn't going to work because it then tries to

Dub and cleaning

2017-01-16 Thread Russel Winder via Digitalmars-d-learn
Is it really the case that Dub does not have a way of cleaning up all the stuff it creates? I tried "dub clean" and it doesn't clean. -- Russel. = Dr Russel Winder t: +44 20 7585 2200 voip:

Re: Dub, SDL, and Subpackages

2017-01-16 Thread rikki cattermole via Digitalmars-d-learn
On 16/01/2017 11:14 PM, Russel Winder via Digitalmars-d-learn wrote: The Dub manual says that: name "mylib" targetType "none" dependency "mylib:component1" version="*" subPackage { name "component1" targetType "library" sourcePaths "component1/source"

Dub, SDL, and Subpackages

2017-01-16 Thread Russel Winder via Digitalmars-d-learn
The Dub manual says that: name "mylib" targetType "none" dependency "mylib:component1" version="*" subPackage { name "component1" targetType "library" sourcePaths "component1/source" importPaths "component1/source" } is reasonable. However whenever I try

Re: Using Dub

2017-01-16 Thread Russel Winder via Digitalmars-d-learn
On Sun, 2017-01-15 at 17:44 +, cym13 via Digitalmars-d-learn wrote: > On Sunday, 15 January 2017 at 13:23:25 UTC, Russel Winder wrote: > > Is there any way of setting dub to default to ldc2 rather than  > > dmd as the compiler of use? (I do not want to have to put  > > --compiler ldc2 on every

Re: Quine using strings?

2017-01-16 Thread Nestor via Digitalmars-d-learn
On Monday, 16 January 2017 at 06:41:50 UTC, Basile B. wrote: I remember on Rosetta to have seen this: module quine; import std.stdio; void main(string[] args) { write(import("quine.d")); } compiles with: dmd path/quine.d -Jpath Very good! By the way, module name and arguments aren't