Re: Why a template with Nullable does not compile?

2019-03-11 Thread Victor Porton via Digitalmars-d-learn
On Tuesday, 12 March 2019 at 05:14:21 UTC, Victor Porton wrote: Why does this not compile? import std.typecons; template FieldInfo(T, Nullable!T default_) { } /usr/lib/ldc/x86_64-linux-gnu/include/d/std/typecons.d(2570,17): Error: `alias T = T;` cannot alias itself, use a qualified name to

Why a template with Nullable does not compile?

2019-03-11 Thread Victor Porton via Digitalmars-d-learn
Why does this not compile? import std.typecons; template FieldInfo(T, Nullable!T default_) { } /usr/lib/ldc/x86_64-linux-gnu/include/d/std/typecons.d(2570,17): Error: `alias T = T;` cannot alias itself, use a qualified name to create an overload set

Re: Easiest way to display images

2019-03-11 Thread Murilo via Digitalmars-d-learn
Hi Adam, how do I set the color of the SimpleWindow background?

Re: Why does D language do not support BigDecimal type?

2019-03-11 Thread Heromyth via Digitalmars-d-learn
On Monday, 11 March 2019 at 15:23:34 UTC, BoQsc wrote: There is Money datatype that can be provided by using a third party package: https://code.dlang.org/packages/money But that's only for money, what about math? Why such fundamental as BigDecimal is still not included into the D language

ggplotd Fixed ratio between x and y axes

2019-03-11 Thread kerdemdemir via Digitalmars-d-learn
How can I configure a fixed ratio between x and y axes in ggplotd ? I easily found what I am looking for in ggplot which ggplotd inspires a lot. http://www.cookbook-r.com/Graphs/Axes_(ggplot2)/ But ggplotd documentation does not have any info about that. Even I go through the source code

inout auto ref escaping a reference to parameter, only errors with vibe Json type, or if inout is there.

2019-03-11 Thread aliak via Digitalmars-d-learn
Hi, I have an error that says "Error: returning `match1(opt)` escapes a reference to parameter `opt`, perhaps annotate with `return`". The code is here: https://run.dlang.io/is/ESZDW4 (It's copied at the end of this post as well) 1) If you remove the inout from line 11. It works. 2) If you

Re: How are (Static) Libraries with Templates Compiled?

2019-03-11 Thread jmh530 via Digitalmars-d-learn
On Monday, 11 March 2019 at 20:11:37 UTC, ag0aep6g wrote: On Monday, 11 March 2019 at 19:53:53 UTC, jmh530 wrote: So what information is in the static library that allows this to take place? None. The information is in in the source or interface file (.d/.di). Templates can't be compiled

Re: How are (Static) Libraries with Templates Compiled?

2019-03-11 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Mar 11, 2019 at 07:53:53PM +, jmh530 via Digitalmars-d-learn wrote: > Suppose I have a file with a simple templated function. I compile that > to a static library. I then compile another file that uses the library > into an executable. When compiled to the static library, you don't >

Re: How are (Static) Libraries with Templates Compiled?

2019-03-11 Thread ag0aep6g via Digitalmars-d-learn
On Monday, 11 March 2019 at 19:53:53 UTC, jmh530 wrote: So what information is in the static library that allows this to take place? None. The information is in in the source or interface file (.d/.di). Templates can't be compiled before they're instantiated.

How are (Static) Libraries with Templates Compiled?

2019-03-11 Thread jmh530 via Digitalmars-d-learn
Suppose I have a file with a simple templated function. I compile that to a static library. I then compile another file that uses the library into an executable. When compiled to the static library, you don't know in advance what types it will call on the templated function, so that must be

Re: Array of byLineCopy ranges behaves as they are byLine

2019-03-11 Thread Paul Backus via Digitalmars-d-learn
On Monday, 11 March 2019 at 17:33:31 UTC, HaraldZealot wrote: Ah yes, I forget about laziness of `map`. BTW, I have found other solution, which is more fit to my initial intention. ```d ReturnType!(std.stdio.File.byLineCopy!(char, immutable(char)))[] ranges; foreach(filename; args[1 .. $]) {

Re: Array of byLineCopy ranges behaves as they are byLine

2019-03-11 Thread HaraldZealot via Digitalmars-d-learn
On Monday, 11 March 2019 at 17:04:56 UTC, ag0aep6g wrote: To avoid the re-evaluation, assign `ranges[0]` to a variable before using it: auto lines = ranges[0]; writeln(lines.front); writeln(lines.front); writeln(lines.front); That should print the same line three times. Ah

Re: Array of byLineCopy ranges behaves as they are byLine

2019-03-11 Thread ag0aep6g via Digitalmars-d-learn
On Monday, 11 March 2019 at 15:23:53 UTC, HaraldZealot wrote: ```d File[] files; foreach(filename; args[1 .. $]) { files ~= File(filename, "r"); } auto ranges = files.map!(a => a.byLineCopy); writeln(ranges[0].front); writeln(ranges[0].front); writeln(ranges[0].front); ``` produces ``` 1 2

Array of byLineCopy ranges behaves as they are byLine

2019-03-11 Thread HaraldZealot via Digitalmars-d-learn
Let assume I have multiple files (like "file1", "file2" and so on). I need to iterate them simultaneously with some logic. I have tried to create random access range of ranges, however, it behaves not as expected. Let "file1" is ``` 1 2 3 4 ``` Then this code ```d File[] files;

Why does D language do not support BigDecimal type?

2019-03-11 Thread BoQsc via Digitalmars-d-learn
There is Money datatype that can be provided by using a third party package: https://code.dlang.org/packages/money But that's only for money, what about math? Why such fundamental as BigDecimal is still not included into the D language itself? There is BigInt. If it is unavoidable to use

Workaround for dub build-path problem

2019-03-11 Thread bitwise via Digitalmars-d-learn
https://github.com/dlang/dub/issues/658 As noted in the above issue, dub runs in the root project directory for all packages, including dependancies. So if any project aside from the root project includes a relative path in it's dub.json, that dub build will break, due to the incorrect

Re: Distinguish float and integer types from string

2019-03-11 Thread XavierAP via Digitalmars-d-learn
On Monday, 11 March 2019 at 15:03:39 UTC, XavierAP wrote: What compiler version are you using? I on the other hand was surprised that I needed the try-catch above, after having already checked isNumeric. The documentation claims that the conversion to int or long would truncate, but my

Re: Distinguish float and integer types from string

2019-03-11 Thread XavierAP via Digitalmars-d-learn
On Saturday, 9 March 2019 at 18:11:09 UTC, Jacob Shtokolov wrote: One of the task was to take a string from STDIN and detect its type. There were a few options: Float, Integer, string and "something else" (which, I think, doesn't have any sense under the scope of the task). Another

Re: Distinguish float and integer types from string

2019-03-11 Thread Johann Lermer via Digitalmars-d-learn
On Saturday, 9 March 2019 at 18:11:09 UTC, Jacob Shtokolov wrote: I tried to use std.conv.to and std.conv.parse, but found that they can't really do this. When I call `data.to!int`, the value of "123.45" will be converted to int! Are you sure? This here works for me: import std.stdio; import

Re: Distinguish float and integer types from string

2019-03-11 Thread Soulsbane via Digitalmars-d-learn
On Saturday, 9 March 2019 at 18:11:09 UTC, Jacob Shtokolov wrote: Hi, Recently, I was trying to solve some funny coding challenges (https://www.techgig.com). The questions were really simple, but I found it interesting because the website allows to use D. One of the task was to take a