Re: `this` and nested structs

2018-05-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 10, 2018 06:31:09 Mike Franklin via Digitalmars-d-learn wrote: > On Thursday, 10 May 2018 at 06:22:37 UTC, Jonathan M Davis wrote: > > Structs don't have that. > > Should they? Honestly, I don't think that classes should have it, but changing it now would break code (most notably

Re: Package method is not virtual and cannot override - a bug or a feature?

2018-05-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 10, 2018 11:52:38 Piotr Mitana via Digitalmars-d-learn wrote: > Given this code: > > abstract class A > { > package @property void x(int x); > package @property int x(); > } > > class B : A > { > package @property override void x(int x) {} > package @property o

Re: property += operator

2018-05-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 10, 2018 18:43:40 SrMordred via Digitalmars-d-learn wrote: > struct T > { > int x; > @property ref X(){ return x; } > @property X(int v) > { > x = v; > } > } > > T t; > t.X += 10; > > The setter 'x = v' are not executed because i´m returning the >

Re: Why are deprecated aliases considered equal for resolution?

2018-05-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 11, 2018 14:02:22 Nicholas Wilson via Digitalmars-d-learn wrote: > - > module a; > > struct foo {} > > deprecated alias bar = foo; > > -- > module b; > struct bar {}; > > > --- > module c; > > import a; > import b; > > void baz(bar b) {} > > Error: `a.bar` at

Re: getOpt with shared

2018-05-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 11, 2018 17:25:44 Danny Arends via Digitalmars-d-learn wrote: > Hey all, > > I have been working on creating a multi-threaded application, so > I have a shared configuration object which hold several command > line parameters (which I fill using getopt). > > The problem is that I get

Re: getOpt with shared

2018-05-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 11, 2018 18:01:18 Danny Arends via Digitalmars-d-learn wrote: > On Friday, 11 May 2018 at 17:49:17 UTC, Jonathan M Davis wrote: > > On Friday, May 11, 2018 17:25:44 Danny Arends via > > > > Digitalmars-d-learn wrote: > >> [...] > > > > getopt is designed to be single-threaded. The ke

Re: getOpt with shared

2018-05-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 11, 2018 14:31:17 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 5/11/18 1:25 PM, Danny Arends wrote: > > Hey all, > > > > I have been working on creating a multi-threaded application, so I have > > a shared configuration object which hold several command line parameters >

Re: Why The D Style constants are written in camelCase?

2018-05-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 15, 2018 08:48:45 Martin Tschierschke via Digitalmars-d- learn wrote: > On Wednesday, 9 May 2018 at 11:52:11 UTC, Jonathan M Davis wrote: > > On Wednesday, May 09, 2018 09:38:14 BoQsc via > > > > Digitalmars-d-learn wrote: > >> [...] > > > > Every language makes its own choices with

Re: Splitting up large dirty file

2018-05-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 15, 2018 20:36:21 Dennis via Digitalmars-d-learn wrote: > I have a file with two problems: > - It's too big to fit in memory (apparently, I thought 1.5 Gb > would fit but I get an out of memory error when using > std.file.read) > - It is dirty (contains invalid Unicode characters, n

Re: Splitting up large dirty file

2018-05-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 16, 2018 08:57:10 Dennis via Digitalmars-d-learn wrote: > I thought it wouldn't be hard to crudely split this file using > D's range functions and basic string manipulation, but the > combination of being to large for a string and having invalid > encoding seems to defeat most sim

Re: Splitting up large dirty file

2018-05-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 17, 2018 21:10:35 Dennis via Digitalmars-d-learn wrote: > On Wednesday, 16 May 2018 at 10:30:34 UTC, Jonathan M Davis wrote: > > For various reasons, that doesn't always hold true like it > > should, but pretty much all of Phobos is written with that > > assumption and will general

Re: is ==

2018-05-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 18, 2018 23:53:12 IntegratedDimensions via Digitalmars-d- learn wrote: > Why does D complain when using == to compare with null? Is there > really any technical reason? if one just defines == null to is > null then there should be no problem. It seems like a pedantic > move by who ev

Re: is ==

2018-05-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 19, 2018 01:27:59 Neia Neutuladh via Digitalmars-d-learn wrote: > On Friday, 18 May 2018 at 23:53:12 UTC, IntegratedDimensions > > wrote: > > Why does D complain when using == to compare with null? Is > > there really any technical reason? if one just defines == null > > to is nul

Re: is ==

2018-05-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 19, 2018 03:32:53 Neia Neutuladh via Digitalmars-d-learn wrote: > > Of course, the most notable case where using == with null is a > > terrible idea is dynamic arrays, and that's the case where the > > compiler _doesn't_ complain. Using == with null and arrays is > > always unclea

Re: is ==

2018-05-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 19, 2018 17:50:50 IntegratedDimensions via Digitalmars-d- learn wrote: > So, ultimately what I feels like is that you are actually arguing > for == null to be interpreted as is null but you don't realize it > yet. Not really, no. Having foo == null be rewritten to foo is null

Re: is ==

2018-05-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 19, 2018 17:13:36 Neia Neutuladh via Digitalmars-d-learn wrote: > I don't think I've ever wanted to distinguish a zero-length slice > of an array from a null array. It's safer if you don't, because it's so easy to end up with a dynamic array that is empty instead of null, and stu

Re: is ==

2018-05-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 20, 2018 01:51:50 IntegratedDimensions via Digitalmars-d- learn wrote: > Simply require == null as is null and be done with it. That would be flat out wrong for dynamic arrays, because then auto result = arr == null and int[] nullArr; auto result = arr == nullArr; would have dif

Re: auto & class members

2018-05-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 20, 2018 16:30:10 Robert M. Münch via Digitalmars-d-learn wrote: > I use the D RX lib [1] and can create a filtered stream using the auto > keyword: > > struct a { > SubjectObject!myType myStream; > ??? mySubStream; > } > > void myfunc(){ > a myA = new a(); > > auto mySubStr

Re: Splitting up large dirty file

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 15:00:09 Dennis via Digitalmars-d-learn wrote: > On Thursday, 17 May 2018 at 21:10:35 UTC, Dennis wrote: > > It's unfortunate that Phobos tells you 'there's problems with > > the encoding' without providing any means to fix it or even > > diagnose it. > > I have to take that

Re: is ==

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 10:01:15 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 5/18/18 9:48 PM, Jonathan M Davis wrote: > > Of > > course, the most notable case where using == with null is a terrible > > idea is dynamic arrays, and that's the case where the compiler > > _doesn't_ compla

Re: UFCS syntax I never saw before.

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 14:00:55 ANtlord via Digitalmars-d-learn wrote: > On Monday, 21 May 2018 at 11:38:12 UTC, SrMordred wrote: > > After all this time I saw this: > > > > writeln = iota = 5; > > > > what?? > > > > I never saw that before! > > > > This is interesting, there is something useful t

Re: is ==

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 14:40:24 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 5/21/18 2:05 PM, Jonathan M Davis wrote: > > The core problem here is that no one reading a piece of code has any way > > of knowing whether the programmer knew what they were doing or not when > > using == n

Re: auto & class members

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 14:55:36 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 5/20/18 1:46 PM, Robert M. Münch wrote: > > On 2018-05-20 17:40:39 +, Robert M. Münch said: > >> Hi Jonathan, great! This got me a step further. So I can declare my > >> member now. But I get an implict c

Re: auto & class members

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 11:13:16 Ali Çehreli via Digitalmars-d-learn wrote: > On 05/20/2018 10:46 AM, Robert M. Münch wrote: > > But I still don't understand why I can't write things explicitly but > > have to use an alias for this. > > Templatized range types work well when they are used as temp

Re: assertNotThrown (and asserts in general)

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 12:44:21 Malte via Digitalmars-d-learn wrote: > I was interested by asserts and how the compiler uses them to > optimize the code. So I looked at the compiler explorer to see > how and found it, it doesn't. > > What I tried to do is turn a std.conv.to!ulong(byte) to a simple

Re: Can I work out error: reinterpreting cast from const(ubyte)* to const(uint)* is not supported in CTFE?

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 18:13:26 Dr.No via Digitalmars-d-learn wrote: > I'm trying to do some hashing at compile time with xxhash > algorithm but I get this error: > > ..\..\..\AppData\Local\dub\packages\xxhash-master\xxhash\src\xxhash.d(39,3 > 7): Error: reinterpreting cast from const(ubyte)* to c

Re: auto & class members

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 16:05:00 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 5/21/18 3:22 PM, Jonathan M Davis wrote: > > That's basically what I was suggesting that he do, but I guess that I > > wasn't clear enough. > > Well one thing that seems clear from this example -- we now have

Re: auto & class members

2018-05-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 22, 2018 10:43:38 Robert M. Münch via Digitalmars-d-learn wrote: > On 2018-05-21 20:17:04 +, Jonathan M Davis said: > > On Monday, May 21, 2018 16:05:00 Steven Schveighoffer via Digitalmars-d- > > > > learn wrote: > >> Well one thing that seems clear from this example -- we now

Re: auto & class members

2018-05-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 22, 2018 10:40:55 Robert M. Münch via Digitalmars-d-learn wrote: > This would require one wrap function per different lambda, right? > Assume I have 50-100 of these. Maybe the myMessage value can be given > as parameter and with this becomes more like a "filter factory". Not > sure

Re: UFCS syntax I never saw before.

2018-05-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 22, 2018 13:48:16 aliak via Digitalmars-d-learn wrote: > On Monday, 21 May 2018 at 18:53:19 UTC, Jonathan M Davis wrote: > > writeln = "foo"; > > > > is legal, and it's dumb, but it hasn't mattered much in > > practice. So, causing a bunch of code breakage in order to > > disallow i

Re: try & catch / repeating code - DRY

2018-05-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 23, 2018 04:07:25 Ali Çehreli via Digitalmars-d-learn wrote: > On 05/23/2018 12:47 AM, Robert M. Münch wrote: > > On 2018-05-22 18:34:34 +, Ali ‡ehreli said: > >> An idiom known in C++ circles is a Lippincott function: > >> > >> > >> https://cppsecrets.blogspot.ca/2013/12/us

Re: How to convert ubyte[] to uint?

2018-05-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 23, 2018 19:36:07 Dr.No via Digitalmars-d-learn wrote: > read fails with both uint and ulong on 64bit platform: > > Error: template std.bitmanip.read cannot deduce function from > argument types !(ulong)(ubyte[8]), candidates are: > C:\ldc2-1.9.0-windows-x64\bin\..\import\std\bi

Re: try & catch / repeating code - DRY

2018-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 24, 2018 19:39:07 Jacob Carlborg via Digitalmars-d-learn wrote: > On 2018-05-24 08:05, Robert M. Münch wrote: > > Hi, great! Thanks for the examples... BTW: Is there a place where such > > generic and fundamental examples are collected? > > Not as far as I know. > > >> void handle

Re: Why char[] is not @nogc on this case

2018-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 24, 2018 23:55:24 SrMordred via Digitalmars-d-learn wrote: > int[] a; > int[] b; > > ()@nogc { > foreach(v ; chain( a,b ) ) printf("%d\n", v); > }(); > > //Ok, everything fine; > > char[] a; > char[] b; > > ()@nogc { > foreach(v ; chain( a,b ) ) printf("%c\n", v); > }(); >

Re: Why char[] is not @nogc on this case

2018-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 25, 2018 00:09:28 SrMordred via Digitalmars-d-learn wrote: > On Friday, 25 May 2018 at 00:04:10 UTC, Adam D. Ruppe wrote: > > On Thursday, 24 May 2018 at 23:55:24 UTC, SrMordred wrote: > >> //Error: @nogc delegate onlineapp.main.__lambda1 cannot call > >> non-@nogc function std.range

Re: What's the purpose of the 'in' keyword ?

2018-05-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 27, 2018 16:28:56 Russel Winder via Digitalmars-d-learn wrote: > On Sun, 2018-05-27 at 13:10 +, Adam D. Ruppe via Digitalmars-d-learn > > wrote: > > On Sunday, 27 May 2018 at 13:02:23 UTC, loloof64 wrote: > > > What's the purpose of this 'in' keyword ? I could not process a > >

Re: Naming conventions for export and import members of a struct

2018-05-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 27, 2018 21:54:42 Per Nordlöw via Digitalmars-d-learn wrote: > The integer type in gmp-z just got export (binary serialization) > support at > > https://github.com/nordlow/gmp-d/pull/8 > > Next up is import (binary deserialization). > > What's the preferred D-style naming convention

Re: What is special about an immutable array of class objects, and why can I not .dup ?

2018-05-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 28, 2018 13:51:49 James Blachly via Digitalmars-d-learn wrote: > Consider the below: > > ``` > class C > { > int x; > } > > struct S > { > int x; > } > > > void main() > { > immutable C[] c = [ new C(), new C()]; > immutable S[] s = [ S(), S() ]; > immutable int[]

Re: Why 'getSymbolsByUDA' filters private members?

2018-05-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 28, 2018 05:43:23 Simen Kjærås via Digitalmars-d-learn wrote: > On Sunday, 27 May 2018 at 17:42:15 UTC, Sobaya wrote: > > I'd like to get symbols that have an UDA. > > > > But when the member is private, it is not obtained. > > > > And I found a comment saying "Filtering inaccessible

Re: Move and CTFE

2018-05-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 30, 2018 20:42:38 Q. Schroll via Digitalmars-d-learn wrote: > It seems one cannot std.algorithm.mutation.move objects > explicitly. Say I have a non-copyable type > > struct NoCopy > { > int payload; // some payload > pure nothrow @nogc @safe @disable: >

Re: Move and CTFE

2018-05-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 30, 2018 22:42:13 Q. Schroll via Digitalmars-d-learn wrote: > On Wednesday, 30 May 2018 at 21:02:07 UTC, Jonathan M Davis wrote: > > On Wednesday, May 30, 2018 20:42:38 Q. Schroll via > > > > Digitalmars-d-learn wrote: > >> It seems one cannot std.algorithm.mutation.move objects

Re: What's the purpose of the 'in' keyword ?

2018-05-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 30, 2018 15:28:53 Ali Çehreli via Digitalmars-d-learn wrote: > On 05/30/2018 03:16 PM, aberba wrote: > > On Sunday, 27 May 2018 at 16:00:15 UTC, Jonathan M Davis wrote: > >> On Sunday, May 27, 2018 16:28:56 Russel Winder via Digitalmars-d-learn > >> > >> wrote: > >>> On Sun, 2018

Re: What's the purpose of the 'in' keyword ?

2018-05-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 30, 2018 22:16:28 aberba via Digitalmars-d-learn wrote: > On Sunday, 27 May 2018 at 16:00:15 UTC, Jonathan M Davis wrote: > > On Sunday, May 27, 2018 16:28:56 Russel Winder via > > > > Digitalmars-d-learn wrote: > >> On Sun, 2018-05-27 at 13:10 +, Adam D. Ruppe via > >> Digita

Re: question about keeeping reference to toStringz()

2018-05-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 31, 2018 01:12:34 Dr.No via Digitalmars-d-learn wrote: > On Wednesday, 30 May 2018 at 20:43:48 UTC, Ali Çehreli wrote: > > On 05/30/2018 01:09 PM, Dr.No wrote: > > > consider a C function with this prototype: > > >> void foo(const char *baa); > > > > > > Does it means I should do:

Re: Generate documentation for mixin'd function?

2018-06-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 01, 2018 21:26:18 rjframe via Digitalmars-d-learn wrote: > Hi > > I'm making an API for a web service, and have a small collection of > endpoints where I'd basically be creating copy+paste functions (a small > enough number that this isn't really that important for this project). I

Re: Confusion/trying to understand CTFE keywords

2018-06-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, June 03, 2018 21:32:06 gdelazzari via Digitalmars-d-learn wrote: > Hello everyone, I'm new here on the forum but I've been exploring > D for quite a while. I'm not an expert programmer by any means, > so this one may be a really silly question and, in that case, > please forgive me. > >

Re: Confusion/trying to understand CTFE keywords

2018-06-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 04, 2018 14:05:28 gdelazzari via Digitalmars-d-learn wrote: > On Monday, 4 June 2018 at 03:18:05 UTC, Jonathan M Davis wrote: > > So, while static _seems_ somewhat inconsistent at first, the > > way it's used is pretty consistent overall. The main > > inconsistency is the places whe

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 05, 2018 11:18:05 Gopan via Digitalmars-d-learn wrote: > On Tuesday, 5 June 2018 at 10:40:20 UTC, Simen Kjærås wrote: > > On Tuesday, 5 June 2018 at 09:36:22 UTC, Gopan wrote: > >> void main() > >> { > >> > >> immutable n = __ctfe ? 1 : 2; > >> int[n] a; > >> assert(a.l

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 05, 2018 22:08:32 Stefan Koch via Digitalmars-d-learn wrote: > On Tuesday, 5 June 2018 at 18:00:05 UTC, Steven Schveighoffer > > wrote: > > No, it's definitely a bug. main is not being evaluated at > > compile time. The real result of this function should be a > > compile-time err

Re: Confusion/trying to understand CTFE keywords

2018-06-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 06, 2018 18:18:16 jmh530 via Digitalmars-d-learn wrote: > On Monday, 4 June 2018 at 03:18:05 UTC, Jonathan M Davis wrote: > > [snip] > > > > If you haven't yet, I'd suggest reading > > Would make a good blog series? What would make a good blog series? Something talking about CTF

Re: Confusion/trying to understand CTFE keywords

2018-06-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 07, 2018 04:41:35 Gopan via Digitalmars-d-learn wrote: > On Tuesday, 5 June 2018 at 22:08:32 UTC, Stefan Koch wrote: > > On Tuesday, 5 June 2018 at 18:00:05 UTC, Steven Schveighoffer > > > > wrote: > >> No, it's definitely a bug. main is not being evaluated at > >> compile time. T

Re: Confusion/trying to understand CTFE keywords

2018-06-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 07, 2018 11:31:13 jmh530 via Digitalmars-d-learn wrote: > On Wednesday, 6 June 2018 at 22:19:58 UTC, Jonathan M Davis wrote: > > On Wednesday, June 06, 2018 18:18:16 jmh530 via > > > > Digitalmars-d-learn wrote: > >> On Monday, 4 June 2018 at 03:18:05 UTC, Jonathan M Davis wrote:

Re: WTF! new in class is static?!?!

2018-06-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 07, 2018 21:07:26 DigitalDesigns via Digitalmars-d-learn wrote: > class A; > > class B > { > A a = new A(); > } > > auto b1 = new B(); > auto b2 = new B(); > > assert(b1.a == b2.a)!! > > > I'm glad I finally found this out! This is not typical behavior > in most languages is

Re: WTF! new in class is static?!?!

2018-06-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 07, 2018 22:43:50 aliak via Digitalmars-d-learn wrote: > On Thursday, 7 June 2018 at 21:32:54 UTC, Jonathan M Davis wrote: > > struct S > > { > > > > int* ptr = new int(42); > > > > } > > Is that supposed to compile? -> https://run.dlang.io/is/SjUEOu > > Error: cannot use non-

Re: Confusion/trying to understand CTFE keywords

2018-06-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 08, 2018 03:51:11 David Bennett via Digitalmars-d-learn wrote: > On Thursday, 7 June 2018 at 04:58:40 UTC, Jonathan M Davis wrote: > > It would be trivial enough to create a wrapper template so that > > you can do something like > > > > immutable n = ctfe!(foo()); > > > > e.g. > >

Re: What is the point of nothrow?

2018-06-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, June 10, 2018 23:59:17 Bauss via Digitalmars-d-learn wrote: > What is the point of nothrow if it can only detect when Exception > is thrown and not when Error is thrown? > > It seems like the attribute is useless because you can't really > use it as protection to write bugless, safe code

Re: What is the point of nothrow?

2018-06-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 11, 2018 04:11:38 Bauss via Digitalmars-d-learn wrote: > I'm very well aware that Error is not supposed to be caught and > that the program is in an invalid state, but ehat I'm trying to > get at is that if nothrow or at least a feature similar existed > that could detect code that

Re: What is the point of nothrow?

2018-06-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 11, 2018 20:45:52 Dave Jones via Digitalmars-d-learn wrote: > On Monday, 11 June 2018 at 00:47:27 UTC, Jonathan M Davis wrote: > > On Sunday, June 10, 2018 23:59:17 Bauss via Digitalmars-d-learn > > > > wrote: > >> What is the point of nothrow if it can only detect when > >> Excepti

Re: What is the point of nothrow?

2018-06-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 12, 2018 17:38:07 wjoe via Digitalmars-d-learn wrote: > On Monday, 11 June 2018 at 00:47:27 UTC, Jonathan M Davis wrote: > > On Sunday, June 10, 2018 23:59:17 Bauss via Digitalmars-d-learn > > wrote: > > Errors are supposed to kill the program, not get caught. As > > such, why does

Re: What is the point of nothrow?

2018-06-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 12, 2018 23:32:55 Neia Neutuladh via Digitalmars-d-learn wrote: > On Monday, 11 June 2018 at 00:47:27 UTC, Jonathan M Davis wrote: > > Why do you care about detecting code that can throw an Error? > > Errors are supposed to kill the program, not get caught. As > > such, why does i

Re: What is the point of nothrow?

2018-06-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 13, 2018 02:02:54 wjoe via Digitalmars-d-learn wrote: > On Tuesday, 12 June 2018 at 18:41:07 UTC, Jonathan M Davis wrote: > > On Tuesday, June 12, 2018 17:38:07 wjoe via Digitalmars-d-learn > > > > wrote: > >> On Monday, 11 June 2018 at 00:47:27 UTC, Jonathan M Davis > >> > >> wr

Re: What is the point of nothrow?

2018-06-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 13, 2018 10:56:41 wjoe via Digitalmars-d-learn wrote: > On Wednesday, 13 June 2018 at 03:14:33 UTC, Jonathan M Davis > > wrote: > > Most programs do not handle the case where they run out of > > memory and cannot continue at that point. For better or worse, > > D's GC was designe

Re: Class qualifier vs struct qualifier

2018-06-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 13, 2018 07:35:25 RazvanN via Digitalmars-d-learn wrote: > Hello, > > I'm having a hard time understanding whether this inconsistency > is a bug or intended behavior: > > immutable class Foo {} > immutable struct Bar {} > > void main() > { > import std.stdio : writeln; >

Re: Class qualifier vs struct qualifier

2018-06-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 13, 2018 14:33:48 Jonathan M Davis via Digitalmars-d- learn wrote: > On Wednesday, June 13, 2018 07:35:25 RazvanN via Digitalmars-d-learn wrote: > > Hello, > > > > I'm having a hard time understanding whether this inconsistency > &g

Re: Class qualifier vs struct qualifier

2018-06-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 14, 2018 08:39:48 RazvanN via Digitalmars-d-learn wrote: > > Honestly, from what I understand of how this works, what I find > > weird is the struct case. immutable on classes does _not_ make > > the class itself immutable. It just makes all of its members > > immutable - hence th

Re: Static Array Idiom not working anymore.

2018-06-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 14, 2018 08:40:10 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 6/14/18 7:07 AM, Guillaume Piolat wrote: > > On Tuesday, 12 June 2018 at 15:35:42 UTC, Steven Schveighoffer wrote: > >> No, that's not what I mean. What I mean is: > >> > >> int[] arr = [1,2,3].s; > >> int

Re: What is the point of nothrow?

2018-06-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 14, 2018 18:11:20 wjoe via Digitalmars-d-learn wrote: > On Wednesday, 13 June 2018 at 20:08:06 UTC, Jonathan M Davis > wrote: > > On Wednesday, June 13, 2018 10:56:41 wjoe via > > The idea is that because your program is in an invalid state, > > attempting a graceful shutdown is u

Re: Class qualifier vs struct qualifier

2018-06-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, June 16, 2018 07:13:28 Timoses via Digitalmars-d-learn wrote: > On Thursday, 14 June 2018 at 17:07:09 UTC, Jonathan M Davis wrote: > > Sure, it would save you a little bit of typing when you do > > something like > > > > auto foo = new Foo; > > > > if makes it immutable for you, but it

Re: typeof on protected field

2018-06-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, June 16, 2018 13:12:13 bauss via Digitalmars-d-learn wrote: > On Saturday, 16 June 2018 at 08:32:38 UTC, DigitalDesigns wrote: > > mixin(`foo!(typeof(T.`~m~`)); > > > > gives me an error about m being protected. > > > > Error: class `X` member `name` is not accessible. > > > > this als

Re: What is the point of nothrow?

2018-06-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, June 16, 2018 18:45:53 wjoe via Digitalmars-d-learn wrote: > What you said earlier: > > On Monday, 11 June 2018 at 00:47:27 UTC, Jonathan M Davis wrote: > > [...] > > > > 2. If the compiler knows that a function can't throw an > > Exception, then it doesn't have to insert any of the Ex

Re: How do you test whether a variable is static or not?

2018-06-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, June 16, 2018 14:55:51 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 7/30/16 8:47 AM, Jonathan M Davis via Digitalmars-d-learn wrote: > > I'm writing some serialization code where I need to skip static > > variables. So, I have a symbol from a struct,

Re: How do you test whether a variable is static or not?

2018-06-16 Thread Jonathan M Davis via Digitalmars-d-learn
On 7/30/16 8:47 AM, Jonathan M Davis via Digitalmars-d-learn > >> > >> wrote: > >> > I'm writing some serialization code where I need to skip > >> > static variables. So, I have a symbol from a struct, and I'd > >> > like to test wheth

Re: How do you test whether a variable is static or not?

2018-06-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, June 16, 2018 22:56:38 DigitalDesigns via Digitalmars-d-learn wrote: > On Saturday, 16 June 2018 at 21:41:37 UTC, Jonathan M Davis wrote: > > On Saturday, June 16, 2018 14:55:51 Steven Schveighoffer via > > > > Digitalmars-d- learn wrote: > >> On 7/30/16

Re: How to list all the manifest constants in a class or struct

2018-06-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, June 17, 2018 02:44:38 Heromyth via Digitalmars-d-learn wrote: > Here is a struct named S: > > struct S > { > enum X = 10; > enum Y > { > i = 10 > } > enum Z = "str"; > struct S {} > class C {} > > static int sx = 0; > __gshared int gx = 0; > > shared void

Re: how to determine of a module or any other symbol is visible?

2018-06-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 18, 2018 21:28:00 rikki cattermole via Digitalmars-d-learn wrote: > On 18/06/2018 9:24 PM, Mr.Bingo wrote: > > On Monday, 18 June 2018 at 09:10:59 UTC, rikki cattermole wrote: > >> On 18/06/2018 9:03 PM, Mr.Bingo wrote: > >>> In the code I posted before about CRC, sometimes I get a

Re: how to determine of a module or any other symbol is visible?

2018-06-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 18, 2018 11:53:50 Cauterite via Digitalmars-d-learn wrote: > On Monday, 18 June 2018 at 09:28:00 UTC, rikki cattermole wrote: > > On 18/06/2018 9:24 PM, Mr.Bingo wrote: > >> On Monday, 18 June 2018 at 09:10:59 UTC, rikki cattermole > >> wrote: > >> This doesn't work with depreciatio

Re: What is the point of nothrow?

2018-06-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 18, 2018 15:22:48 wjoe via Digitalmars-d-learn wrote: > On Saturday, 16 June 2018 at 21:25:01 UTC, Jonathan M Davis wrote: > > every feature that you can't use in betterC is considered a > > loss, and efforts are being made to make more of them work. > > There's always going to be a

Re: Nothrow std.conv.to with explicit default value

2018-06-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 20, 2018 09:37:00 Per Nordlöw via Digitalmars-d-learn wrote: > On Wednesday, 20 June 2018 at 09:27:14 UTC, Per Nordlöw wrote: > > On Monday, 18 June 2018 at 21:10:03 UTC, Steven Schveighoffer > > > > wrote: > >> It just means re-doing std.conv.to, which is pretty hairy, but > >>

Re: What is the point of nothrow?

2018-06-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 21, 2018 13:16:28 wjoe via Digitalmars-d-learn wrote: > On Wednesday, 20 June 2018 at 12:22:33 UTC, Kagamin wrote: > > Do you know how to extract information from it on an unfamiliar > > OS? Reading stack trace is easier and self-evident. > > Counter question: How do you develop

Re: what is the point of functor ?

2018-06-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 22, 2018 14:06:06 Flaze07 via Digitalmars-d-learn wrote: > recently, I visited the glossary and saw that functor exist in > D...I know that functor exist C++ as a way to easily allow higher > order function, but since D already has function and delegates, > is there a point to funct

Re: Determine if CTFE or RT

2018-06-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 25, 2018 05:03:26 Mr.Bingo via Digitalmars-d-learn wrote: > The compiler should be easily able to figure out that foo(3) can > be precomputed(ctfe'ed) and do so. It can already do this, as you > say, by forcing enum on it. Why can't the compiler figure it out > directly? The big pr

Re: Determine if CTFE or RT

2018-06-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 25, 2018 05:47:30 Mr.Bingo via Digitalmars-d-learn wrote: > The problem then, if D can't arbitrarily use ctfe, means that > there should be a way to force ctfe optionally! If you want to use CTFE, then give an enum the value of the expression you want calculated. If you want to do

Re: foreach / mutating iterator - How to do this?

2018-06-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 25, 2018 17:29:23 Robert M. Münch via Digitalmars-d-learn wrote: > I have two foreach loops where the inner should change the iterator > (append new entries) of the outer. > > foreach(a, candidates) { > foreach(b, a) { > if(...) candidates ~= additionalCandidate; > } > }

Re: Nullable!T with T of class type

2018-06-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 25, 2018 19:40:30 kdevel via Digitalmars-d-learn wrote: > Just stumbled over the following design: > > class S {...} > > class R { > >Nullable!S s; > > } > > s was checked in code like > > R r; > > if (r.s is null) >throw new Exception ("some erro

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: 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: 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: 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: Struct template cannot deduce function from argument types

2018-06-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 27, 2018 16:19:56 Luka Aleksic via Digitalmars-d-learn wrote: > Hello, > > In the following code: > > T first; > U second; > > this(T arg_first, U arg_second) { > first = arg_first; > second = arg_second; > } > }; > > void main() { > > pair!(char, uint) p1

Re: Is there a way to get the address of the function that would be used in Implicit Function Template Instantiation?

2018-06-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 27, 2018 22:34:46 Nathan S. via Digitalmars-d-learn wrote: > Let's say there's a function template `doImpl` and `doImpl(x)` > compiles thanks to IFTI. Is there any way to get the address of > the function that would be called in `doImpl(x)`? You could explicitly instantiate the

Re: Is there a way to get the address of the function that would be used in Implicit Function Template Instantiation?

2018-06-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 27, 2018 22:59:03 Nathan S. via Digitalmars-d-learn wrote: > On Wednesday, 27 June 2018 at 22:39:26 UTC, Jonathan M Davis > > wrote: > > You could explicitly instantiate the function template and then > > take its address. > > Explicitly instantiating the template can result in

Re: turn range into tuple ?

2018-06-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 28, 2018 09:26:10 Flaze07 via Digitalmars-d-learn wrote: > On Thursday, 28 June 2018 at 08:52:33 UTC, Simen Kjærås wrote: > > On Thursday, 28 June 2018 at 08:36:54 UTC, Flaze07 wrote: > >> is there some sort of ways to turn range into tuple ? ( an > >> array preferably ) > >> e.g

Re: Nullable!T with T of class type

2018-06-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 28, 2018 18:10:07 kdevel via Digitalmars-d-learn wrote: > On Tuesday, 26 June 2018 at 21:54:49 UTC, Jonathan M Davis wrote: > > [H]onestly, I don't understand why folks keep trying to put > > nullable types in Nullable in non-generic code. > > How do you signify that a struct memb

Re: Nullable!T with T of class type

2018-06-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 28, 2018 19:45:52 kdevel via Digitalmars-d-learn wrote: > On Thursday, 28 June 2018 at 19:22:38 UTC, Jonathan M Davis wrote: > > Nullable makes sense in generic code, because the code isn't > > written specifically for them, but something like > > Nullable!MyClass in non-generic c

Re: errnoEnforce: which imports?

2018-06-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 29, 2018 01:25:39 kdevel via Digitalmars-d-learn wrote: > In https://dlang.org/phobos/std_exception.html#errnoEnforce this > example is shown: > > --- > auto f = errnoEnforce(fopen("data.txt")); > auto line = readln(f); > enforce(line.length); // expect a non-empty line > --- > > I

Re: Why tuples are not ranges?

2018-06-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 29, 2018 05:52:03 Alex via Digitalmars-d-learn wrote: > On Thursday, 28 June 2018 at 19:02:51 UTC, Ali Çehreli wrote: > > On 06/28/2018 11:08 AM, Mr.Bingo wrote: > > > Thanks, why not add the ability to pass through ranges and > > > > arrays and > > > > > add it to phobos? > > > > M

Re: errnoEnforce: which imports?

2018-06-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 29, 2018 09:08:40 kdevel via Digitalmars-d-learn wrote: > On Friday, 29 June 2018 at 02:28:04 UTC, Jonathan M Davis wrote: > > [...] really, that example needs to be completely redone. > > Shall I create a bug report? Yes. Aside from someone trying it out and complaining about it,

Re: Linker error for core.sys.windows.winuser imports when compiling as 64 bit.

2018-06-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 01, 2018 00:42:30 spikespaz via Digitalmars-d-learn wrote: > Hey guys, I'm getting a linker error when compiling with DMD > `-m63` that I don't get as 23 bit. > > I'm importing `ShowWindow` from `core.sys.windows.winuser`, and I > get the following: > > C:\D\dmd2\windows\bin\lld-lin

Re: Issues with undefined symbols when using Vibe on Windows

2018-07-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, July 02, 2018 18:26:27 Chris M. via Digitalmars-d-learn wrote: > On Monday, 2 July 2018 at 17:33:20 UTC, Bauss wrote: > > On Monday, 2 July 2018 at 12:53:19 UTC, Chris M. wrote: > >> On Friday, 29 June 2018 at 20:08:49 UTC, Chris M. wrote: > >>> On Friday, 29 June 2018 at 19:53:27 UTC, b

Re: Dynamic arrays / ~= giving an exception...

2018-07-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, July 02, 2018 14:46:28 Steven Schveighoffer via Digitalmars-d- learn wrote: > It should work. We need more context to try and help figure it out. Even > if you can't post the entire program, maybe more context from mystruct. If the program size is too large to show a good example, then

<    1   2   3   4   5   6   7   8   9   10   >