Re: Auto keyword and when to use it

2018-08-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, August 21, 2018 9:04:31 AM MDT Steven Schveighoffer via Digitalmars-d-learn wrote: > On 8/20/18 9:15 PM, Mike Parker wrote: > > I tend to use type inference liberally, almost always with > > const/immutbale locals, though I tend to use auto only when the type > > name is longer than

Re: Generically call a function on Variant's payload?

2018-08-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 20, 2018 8:29:30 PM MDT Nick Sabalausky (Abscissa) via Digitalmars-d-learn wrote: > On 08/20/2018 04:34 PM, Jonathan M Davis wrote: > > foreach(T; TypesThatVariantHolds) > > Yea, that's what I would've just done, but I wanted to support > user-created types not already

Re: Generically call a function on Variant's payload?

2018-08-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 20, 2018 1:38:13 PM MDT Nick Sabalausky (Abscissa) via Digitalmars-d-learn wrote: > There are a bunch of discriminated union types available for D, but the > only one I'm aware of that *doesn't* require a finite-sized list of > types known ahead-of-time is Phobos's Variant. The

Re: ushort + ushort = int?

2018-08-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 20, 2018 4:29:56 AM MDT Andrey via Digitalmars-d-learn wrote: > On Monday, 20 August 2018 at 09:56:13 UTC, Jonathan M Davis wrote: > > It's a combination of keeping the C semantics (in general, C > > code is valid D code with the same semantics, or it won't > > compile) and the

Re: ushort + ushort = int?

2018-08-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 20, 2018 3:19:04 AM MDT Andrey via Digitalmars-d-learn wrote: > On Monday, 20 August 2018 at 08:49:00 UTC, rikki cattermole wrote: > > Yes. On x86 int's will be faster just an FYI so it does make > > sense to use them for computation. > > Inconveniently always use casts. Why in

Re: Generically call a function on Variant's payload?

2018-08-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 19, 2018 9:08:39 PM MDT Nick Sabalausky (Abscissa) via Digitalmars-d-learn wrote: > On 08/19/2018 10:23 PM, Jonathan M Davis wrote: > > On Sunday, August 19, 2018 6:33:06 PM MDT Nick Sabalausky (Abscissa) via > > > > Digitalmars-d-learn wrote: > >> Maybe something involving

Re: Generically call a function on Variant's payload?

2018-08-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 19, 2018 6:33:06 PM MDT Nick Sabalausky (Abscissa) via Digitalmars-d-learn wrote: > On 08/19/2018 08:27 PM, Nick Sabalausky (Abscissa) wrote: > > Suppose I've wrapped a Variant in a struct/class which ensures the > > Variant *only* ever contains types which satisfy a particular

Re: Are properties mature enough?

2018-08-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 19, 2018 12:32:17 PM MDT QueenSvetlana via Digitalmars-d- learn wrote: > In the D Style Guide, it says: > > Properties > https://dlang.org/dstyle.html#properties > > Functions should be property functions whenever appropriate. In > particular, getters and setters should generally

Re: Set optional function parameter

2018-08-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 17, 2018 2:52:53 AM MDT Andrey via Digitalmars-d-learn wrote: > Hello, > > In D there is a nice function: > > auto Tuple!(int,"status",string,"output") executeShell ( > > > > scope const(char)[] command, > > const(string[string]) env = cast(const(string[string]))null, > >

Re: How to declare static compile-time assoc array inside struct?

2018-08-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 17, 2018 9:59:18 AM MDT Steven Schveighoffer via Digitalmars-d-learn wrote: > On 8/13/18 9:21 AM, Andrey wrote: > > On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote: > >> You must use a module constructor to initialize it. > > > > Tried this: > > static this() >

Re: Phobos docs in pdf?

2018-08-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 17, 2018 5:19:11 AM MDT SeanC4S via Digitalmars-d-learn wrote: > I used CUPS to print as pdf individual pages from the standard > library. I want to get all the basic information I need easily at > hand. > I used unpredictableSeed in my code. It seems to be a property > of

Re: Phobos docs in pdf?

2018-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, August 16, 2018 10:36:34 PM MDT SeanC4s via Digitalmars-d-learn wrote: > I never program with a computer connected on-line. I need the > standard library docs in some off-line format. Personally, I'd just look at the source code then, but the dlang.org build does seem to have a pdf

Re: A devil self reference

2018-08-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, August 15, 2018 10:40:49 AM MDT Alex via Digitalmars-d-learn wrote: > Hi all. > Finally, I arrived at something like this: > > ´´´ > void main() > { > S!(sarr)[] sarr; > } > > struct S(alias Reference) > { > size_t id() > in > { > // not static assert, only because a

Re: tryTo: non-throwing variant of std.conv.to

2018-08-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, August 15, 2018 3:21:29 AM MDT Per Nordlöw via Digitalmars-d- learn wrote: > Have anybody thought about non-throwing variants of std.conv.to > typically named `tryTo` > similar to what Folly > > https://github.com/facebook/folly/blob/master/folly/docs/Conv.md#non-throw >

Re: Concat enum of strings into one string

2018-08-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, August 14, 2018 8:37:33 AM MDT Andrey via Digitalmars-d-learn wrote: > On Tuesday, 14 August 2018 at 14:07:23 UTC, Timoses wrote: > > Here's one version: > > > > template StringEnumValues(alias Enum) > > { > > > > import std.traits : EnumMembers; > > string[]

Re: Enum and CTFE function call

2018-08-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, August 14, 2018 4:03:11 AM MDT Michael via Digitalmars-d-learn wrote: > The page does state that enums should trigger CTFE though. CTFE is triggered when a value must be known at compile-time. So, if you have something like enum a = foo(); foo gets called at compile-time, because

Re: Enum and CTFE function call

2018-08-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, August 14, 2018 3:12:30 AM MDT ixid via Digitalmars-d-learn wrote: > This will not compile as it says n is not known at compile time: > > auto fun(int n) { > static foreach(i;0..n) > mixin(i.to!string ~ ".writeln;"); > return; > } > > enum value = 2; > > > void main() { >

Re: How to declare static compile-time assoc array inside struct?

2018-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 13, 2018 6:14:56 AM MDT Andrey via Digitalmars-d-learn wrote: > On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote: > > Unsupported. AA's don't go between CT and RT. You must use a > > module constructor to initialize it. > > Will be supported in future? Maybe,

Re: string to char conv

2018-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 13, 2018 6:42:02 PM MDT zeus via Digitalmars-d-learn wrote: > On Tuesday, 14 August 2018 at 00:24:53 UTC, Jonathan M Davis > > wrote: > > On Monday, August 13, 2018 6:06:22 PM MDT zeus via > > > > Digitalmars-d-learn wrote: > >> [...] > > > > Why are you casting the string to a

Re: string to char conv

2018-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 13, 2018 6:24:53 PM MDT Jonathan M Davis via Digitalmars- d-learn wrote: > On Monday, August 13, 2018 6:06:22 PM MDT zeus via Digitalmars-d-learn > > wrote: > > i have the following code in d and i get as result 4D77EB, also i > > have the following cod

Re: string to char conv

2018-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 13, 2018 6:06:22 PM MDT zeus via Digitalmars-d-learn wrote: > i have the following code in d and i get as result 4D77EB, also i > have the following code in c++ wich give me as results > 0xABCDEF123abcdef12345678909832190 how i can get in d >

Re: SysTime comparesin - dropMiliseconds

2018-08-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 12, 2018 1:50:44 PM MDT User via Digitalmars-d-learn wrote: > I have to synchronize a directory. If remote file is newer I copy > to local. If local file is newer I copy it to remote server. For > some reason remote timestamp does not contain milliseconds, so > comparison

Re: How do you put log calls in constructors when they may be created in a static context?

2018-08-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, August 9, 2018 7:15:58 AM MDT aliak via Digitalmars-d-learn wrote: > On Thursday, 9 August 2018 at 12:01:42 UTC, Jonathan M Davis > > wrote: > > On Thursday, August 9, 2018 2:37:49 AM MDT aliak via > > > > Digitalmars-d-learn wrote: > >> On Wednesday, 8 August 2018 at 23:47:22 UTC,

Re: How do you put log calls in constructors when they may be created in a static context?

2018-08-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, August 9, 2018 2:37:49 AM MDT aliak via Digitalmars-d-learn wrote: > On Wednesday, 8 August 2018 at 23:47:22 UTC, Jonathan M Davis > > wrote: > > On Wednesday, August 8, 2018 3:54:34 PM MDT aliak via > > > > Digitalmars-d-learn wrote: > >> I'm trying to debug stuff, so I want to add

Re: How do you put log calls in constructors when they may be created in a static context?

2018-08-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, August 8, 2018 3:54:34 PM MDT aliak via Digitalmars-d-learn wrote: > I'm trying to debug stuff, so I want to add verbose logging > > struct S(T) { >this() { > writeln("created S(T) with properties and ID"); >} > } > > static a = S!int(); // bah > > I guess users can

Re: if(int a = 0) lowered to "if (int a = (int a = 1;) , a)" ?

2018-08-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, August 8, 2018 5:58:50 AM MDT aliak via Digitalmars-d-learn wrote: > Found this out while just looking at lowerings. Wondering if > anyone knows the semantics involved here and where they are > documented? It's particularly useful when dealing with stuff like C functions that

Re: Implicit conversion by return

2018-08-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, August 8, 2018 2:15:16 AM MDT Hakan Aras via Digitalmars-d- learn wrote: > Given this: > > struct Num > { > this(int a) {} > } > > Is there any reason why this works: > > Num n = 5; > > but this doesnt: > > Num funk() > { > return 5; > } > > > I understand that I can

Re: Eponymous template member from a template mixin

2018-08-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, August 04, 2018 17:10:32 Steven Schveighoffer via Digitalmars- d-learn wrote: > On 8/4/18 4:10 PM, Yuxuan Shui wrote: > > This doesn't work: > > > > template A() { > > > > void B() {}; > > > > } > > template B() { > > > > mixin A!(); > > > > } > > void main() { > > > >

Re: What does auto std.stdio.File.ByChunkImpl byChunk (ulong chunkSize ); mean?

2018-08-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 03, 2018 17:47:53 kdevel via Digitalmars-d-learn wrote: > On Friday, 3 August 2018 at 17:27:07 UTC, Adam D. Ruppe wrote: > > But remember, this is documentation that just happens to look > > like code, so it is intended to be legible by people rather > > than the compiler. > > I

Re: Disabling struct destructor illegal?

2018-07-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 19, 2018 10:04:34 RazvanN via Digitalmars-d-learn wrote: > I just don't understand why you would ever mark the destructor of > a struct with @disable. When is that useful? If it's not, why not > just forbit it? There's nothing special about destructors here. You can @disable any

Re: vibe.d: problematic "Non-@safe methods are deprecated in REST interfaces"

2018-07-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, 11 July 2018 01:46:10 MDT Piotr Mitana via Digitalmars-d-learn wrote: > On Tuesday, 10 July 2018 at 13:24:43 UTC, WebFreak001 wrote: > > It's supposed to make webservers safe and not crash because of > > segmentation faults, etc. > > > > If you still want to write code like you are

Re: vibe.d: problematic "Non-@safe methods are deprecated in REST interfaces"

2018-07-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 10 July 2018 07:24:43 MDT WebFreak001 via Digitalmars-d-learn wrote: > On Tuesday, 10 July 2018 at 13:14:24 UTC, Piotr Mitana wrote: > > Hello, > > > > I've recently started building a little REST application on > > vibe.d. I decided to use the "database" library, as I need to > >

Re: guard clause style static if

2018-07-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 10 July 2018 05:38:33 MDT kdevel via Digitalmars-d-learn wrote: > I would like to suggest an extension of the language by > introducing > > static return Expression_opt; > > which shall have the effect of a return plus that the remaining > lines in the current block are treated as

Re: guard clause style static if

2018-07-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 10 July 2018 05:52:59 MDT kdevel via Digitalmars-d-learn wrote: > On Saturday, 7 July 2018 at 13:03:32 UTC, rikki cattermole wrote: > > void func() { > > > > return; > > > > func2(); > > > > } > > > > Which is clearly an error. Hence why you need to add else block. > > There is

Re: immutable / inout / pure headaches

2018-07-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 06, 2018 11:10:27 Timoses via Digitalmars-d-learn wrote: > I dared once again getting into immutable by adding an > "immutable" keyword which causes a chain of actions to be taken. > I feel like I'm lost in a jungle of immutable, inout and pure > (perhaps more will join the

Re: Why is it hard to make Qt bindings?

2018-07-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 05, 2018 11:42:39 drug via Digitalmars-d-learn wrote: > There were several attempts to make Qt binding for dlang, but either > they has failed or has been stalled. It would be nice to collect that > experience. Considering 2.081 supports C++ special member (not all but >

Re: Cleanup class after method?

2018-07-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 05, 2018 05:47:20 Flaze07 via Digitalmars-d-learn wrote: > On Wednesday, 4 July 2018 at 16:02:25 UTC, Jonathan M Davis wrote: > > -dip1000 fully implements scope so that it verifies that no > > reference escapes, but it's not ready yet, let alone the > > default behavior. > > > >

Re: Cleanup class after method?

2018-07-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 04, 2018 15:47:25 JN via Digitalmars-d-learn wrote: > Imagine I have a very short-lived class: > > void print(File f) > { > PrinterManager pm = new PrinterManager(); > pm.print(f); > } > > My understanding is that PrinterManager will be GC allocated, and > when it goes

Re: Inference of auto storage classes for interface function return type

2018-07-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 04, 2018 14:07:35 Timoses via Digitalmars-d-learn wrote: > How can I return inferred storage class from interface functions? > I can't use auto as return value in interface. Neither can I use > "inout" as I don't pass a parameter. > > // Ref Type > interface IRef > { >

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 21:20:26 Seb via Digitalmars-d-learn wrote: > On Monday, 2 July 2018 at 19:24:38 UTC, Chris M. wrote: > > On Monday, 2 July 2018 at 18:48:16 UTC, Jonathan M Davis wrote: > >> On Monday, July 02, 2018 18:26:27 Chris M. via > >> > >> Digitalmars-d-learn wrote: > >>> On

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

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,

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: > >

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: Why tuples are not ranges?

2018-06-29 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? > > > >

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: 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

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

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: 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: 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

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)

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(";");

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

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

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() > >> { > >> > >>

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

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: 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: 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

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

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: 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-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

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

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

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 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 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 whether it's st

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, and I

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

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

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

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

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; > >>

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

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 > > is

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: 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

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 > >> > >>

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

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

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 > >>

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-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

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: 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

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: 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: 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.

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

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

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; > >>

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

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: 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: 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: 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 > >>

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,

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

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