Re: Visual D 0.47.0 released

2018-06-26 Thread Rainer Schuetze via Digitalmars-d-learn
On 26/06/2018 16:25, Robert M. Münch wrote: On 2018-06-24 13:08:53 +, Rainer Schuetze said: a new release of Visual D has just been uploaded. Major changes are * improved Visual C++ project integration: better dependencies,    automatic libraries, name demangling * new project wizard *

Re: Catching std.conv.ConvException in readf causes a buffer overrun

2018-06-26 Thread Shigeki Karita via Digitalmars-d-learn
On Wednesday, 27 June 2018 at 02:39:49 UTC, Shigeki Karita wrote: import std.stdio; import std.conv; void main() { int i; try { readf("%d\n", &i); // "a" } catch (ConvException e) { auto s = readln(); writeln(s); // "aa", "aaa" or SEGV ??? } } https://wan

Catching std.conv.ConvException in readf causes a buffer overrun

2018-06-26 Thread Shigeki Karita via Digitalmars-d-learn
import std.stdio; import std.conv; void main() { int i; try { readf("%d\n", &i); // "a" } catch (ConvException e) { auto s = readln(); writeln(s); // "aa", "aaa" or SEGV ??? } } https://wandbox.org/permlink/NMYNjpOgQtfUprBQ I just want to retry reading if

Re: CustomString and string constraints

2018-06-26 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 22:16:28 UTC, Jonathan M Davis wrote: If what you're asking is whether it's possible for a template constraint that uses something like isSomeString will ever match a user-defined type, then the answer is no. Thats exactly what I wanted xD. My idea was that if you

Re: CustomString and string constraints

2018-06-26 Thread Jonathan M Davis via Digitalmars-d-learn
n Tuesday, June 26, 2018 17:14:08 SrMordred via Digitalmars-d-learn wrote: > Is possible to make a Custom Struct String work for D string > constraints? > > eg: > > struct MyString > { > char[] arr; > alias arr this; > } > > void getString( char[] str ){} > > MyString().split(";"); //oops

Re: Nullable!T with T of class type

2018-06-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 26, 2018 19:03:20 kdevel via Digitalmars-d-learn wrote: > On Monday, 25 June 2018 at 22:58:41 UTC, Jonathan M Davis wrote: > > On Monday, June 25, 2018 19:40:30 kdevel via > > > > Digitalmars-d-learn wrote: > >> R r; > >> > >> if (r.s is null) > >> > >>throw new Exc

Re: template recursion

2018-06-26 Thread Nathan S. via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 20:47:27 UTC, Steven Schveighoffer wrote: Naming the hook for `put` the same thing as the global function was one of the biggest mistakes in the range library. I almost think we would be better off to deprecate that and pick another hook name. If you ever do that i

Re: template recursion

2018-06-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/26/18 6:01 AM, ag0aep6g wrote: On line 23, you're apparently trying to call std.range.put (which would in turn call tarr[t].put). But being in a method that is itself called "put", that line is instead interpreted as a recursive call (which fails). To refer to std.range.put, you have to p

Re: Nullable!T with T of class type

2018-06-26 Thread kdevel via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 14:32:59 UTC, Nathan S. wrote: On Monday, 25 June 2018 at 19:40:30 UTC, kdevel wrote: Is it possible to "lower" the Nullable operations if T is a class type such that there is only one level of nullification? Yes: https://run.dlang.io/is/hPxbyf template Null

Re: Nullable!T with T of class type

2018-06-26 Thread kdevel via Digitalmars-d-learn
On Monday, 25 June 2018 at 22:58:41 UTC, Jonathan M Davis wrote: On Monday, June 25, 2018 19:40:30 kdevel via Digitalmars-d-learn wrote: R r; if (r.s is null) throw new Exception ("some error message"); [...] Why can't this programming error be detected at compile time? If

Re: First run after build on Windows is slow

2018-06-26 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 12:58:29 UTC, Adam D. Ruppe wrote: On Tuesday, 26 June 2018 at 12:40:05 UTC, phs wrote: Although, it's a little bit strange because I have never had this issue with my C++ development. The c++ compiler and runtime libraries are common enough that the antivirus real

Re: How do I call this tamplte function?

2018-06-26 Thread Ali Çehreli via Digitalmars-d-learn
On 06/26/2018 10:37 AM, Rib wrote: to get get() from std.net.curl return a ubyte[] and use my http instance, all those failed: string link = "http://...";; auto client = HTTP(); // set some client attributes... auto fileContents = get!(AutoProtocol, ubyte)(link, client); auto fileContents = get

How do I call this tamplte function?

2018-06-26 Thread Rib via Digitalmars-d-learn
to get get() from std.net.curl return a ubyte[] and use my http instance, all those failed: string link = "http://...";; auto client = HTTP(); // set some client attributes... auto fileContents = get!(AutoProtocol, ubyte)(link, client); auto fileContents = get!(ubyte)(link, client); auto fileCon

CustomString and string constraints

2018-06-26 Thread SrMordred via Digitalmars-d-learn
Is possible to make a Custom Struct String work for D string constraints? eg: struct MyString { char[] arr; alias arr this; } void getString( char[] str ){} MyString().split(";"); //oops, type mismatch getString( MyString() ); //fine, implicit conversion isSomeString!(char[]).writel

Re: Nullable!T with T of class type

2018-06-26 Thread Nathan S. via Digitalmars-d-learn
On Monday, 25 June 2018 at 22:58:41 UTC, Jonathan M Davis wrote: Java does try to force you to initialize stuff (resulting in annoying false positives at times), but in general, it still can't guarantee when a variable is null or not and is forced to insert runtime null checks. Java can be so

Re: Nullable!T with T of class type

2018-06-26 Thread Nathan S. via Digitalmars-d-learn
On Monday, 25 June 2018 at 19:40:30 UTC, kdevel wrote: Is it possible to "lower" the Nullable operations if T is a class type such that there is only one level of nullification? Yes: https://run.dlang.io/is/hPxbyf template Nullable(S) { import std.traits : isPointer, isDynamicArray;

Re: Visual D 0.47.0 released

2018-06-26 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-06-24 13:08:53 +, Rainer Schuetze said: a new release of Visual D has just been uploaded. Major changes are * improved Visual C++ project integration: better dependencies, automatic libraries, name demangling * new project wizard * mago debugger: show vtable, dynamic type of inte

Re: alias symbol name

2018-06-26 Thread Radu via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 12:19:16 UTC, Jonathan M Davis wrote: On Tuesday, June 26, 2018 11:28:11 Radu via Digitalmars-d-learn wrote: > [...] Ha! :) yeah I was pretty sure this will not work. I'm looking to generate some custom wrappers and knowing when something is really `size_t` is impo

Re: First run after build on Windows is slow

2018-06-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 12:40:05 UTC, phs wrote: Although, it's a little bit strange because I have never had this issue with my C++ development. The c++ compiler and runtime libraries are common enough that the antivirus realizes it is nothing special, but since D is more obscure it just

Re: First run after build on Windows is slow

2018-06-26 Thread phs via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 12:26:45 UTC, rikki cattermole wrote: On 27/06/2018 12:25 AM, phs wrote: Hello. I've made a simple hello world program using dub and dmd for Windows. Everything works well, except that every first run after each rebuild takes around 3 seconds just to start up. Is it

First run after build on Windows is slow

2018-06-26 Thread phs via Digitalmars-d-learn
Hello. I've made a simple hello world program using dub and dmd for Windows. Everything works well, except that every first run after each rebuild takes around 3 seconds just to start up. Is it normal at all?

Re: First run after build on Windows is slow

2018-06-26 Thread rikki cattermole via Digitalmars-d-learn
On 27/06/2018 12:25 AM, phs wrote: Hello. I've made a simple hello world program using dub and dmd for Windows. Everything works well, except that every first run after each rebuild takes around 3 seconds just to start up. Is it normal at all? Its normal if you don't add an exclusion for that

Re: alias symbol name

2018-06-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 26, 2018 11:28:11 Radu via Digitalmars-d-learn wrote: > > I'm pretty sure that that's impossible. As I understand it, the > > compiler basically just replaces aliases with what they refer > > to and doesn't care what the original type was. And they > > _definitely_ don't affect man

Re: alias symbol name

2018-06-26 Thread Radu via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 10:19:44 UTC, Jonathan M Davis wrote: On Tuesday, June 26, 2018 09:47:44 Radu via Digitalmars-d-learn wrote: On Tuesday, 26 June 2018 at 09:24:15 UTC, Stefan Koch wrote: > On Tuesday, 26 June 2018 at 09:14:11 UTC, Radu wrote: >> Consider this https://run.dlang.io/is/H

Re: alias symbol name

2018-06-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 26, 2018 09:47:44 Radu via Digitalmars-d-learn wrote: > On Tuesday, 26 June 2018 at 09:24:15 UTC, Stefan Koch wrote: > > On Tuesday, 26 June 2018 at 09:14:11 UTC, Radu wrote: > >> Consider this https://run.dlang.io/is/HyY2qG > >> > >> --- > >> void main() > >> { > >> > >> impor

Re: template recursion

2018-06-26 Thread Alex via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 10:01:06 UTC, ag0aep6g wrote: On line 23, you're apparently trying to call std.range.put (which would in turn call tarr[t].put). But being in a method that is itself called "put", that line is instead interpreted as a recursive call (which fails). To refer to std.ran

Re: template recursion

2018-06-26 Thread ag0aep6g via Digitalmars-d-learn
On 06/26/2018 11:35 AM, Alex wrote: ´´´ import std.range; void main() { T.member.tarr.length = 42; //put(T.member, 4); // line 6 T.member.put(4); // line 7 } struct T { void put(Type)(Type t){} // line 13 static B member; } struct B { T[] tarr; void put(Typ

Re: alias symbol name

2018-06-26 Thread Radu via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 09:24:15 UTC, Stefan Koch wrote: On Tuesday, 26 June 2018 at 09:14:11 UTC, Radu wrote: Consider this https://run.dlang.io/is/HyY2qG --- void main() { import std.traits; size_t s; pragma(msg, typeof(s).stringof); pragma(msg, mangledName!(typeof(s)));

template recursion

2018-06-26 Thread Alex via Digitalmars-d-learn
Hi all, I have a strange case of template recursion, which I don't know how to solve: ´´´ import std.range; void main() { T.member.tarr.length = 42; //put(T.member, 4); // line 6 T.member.put(4); // line 7 } struct T { void put(Type)(Type t){} // line 13

Re: alias symbol name

2018-06-26 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 09:14:11 UTC, Radu wrote: Consider this https://run.dlang.io/is/HyY2qG --- void main() { import std.traits; size_t s; pragma(msg, typeof(s).stringof); pragma(msg, mangledName!(typeof(s))); pragma(msg, mangledName!s); } --- It outputs: --- ulong m

alias symbol name

2018-06-26 Thread Radu via Digitalmars-d-learn
Consider this https://run.dlang.io/is/HyY2qG --- void main() { import std.traits; size_t s; pragma(msg, typeof(s).stringof); pragma(msg, mangledName!(typeof(s))); pragma(msg, mangledName!s); } --- It outputs: --- ulong m _D9onlineapp4mainFZ1sm --- I'm looking for a way to g

Re: Making sense of recursion

2018-06-26 Thread Timoses via Digitalmars-d-learn
On Monday, 25 June 2018 at 17:45:01 UTC, zbr wrote: Hi, this question is not specifically D related but I'll just ask anyway. Consider the following snippet: void mergeSort(int[] arr, int l, int r) { if (l < r) // 1 { int m = l+(r-l)/2;// 2 me