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

2018-06-17 Thread Heromyth via Digitalmars-d-learn
On Sunday, 17 June 2018 at 04:32:29 UTC, Jonathan M Davis wrote: 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;

range.put() to Empty Array Causes Error?

2018-06-17 Thread Vijay Nayar via Digitalmars-d-learn
This code breaks with the following error: void main() { import std.range; int[] vals = []; vals.put(3); } /src/phobos/std/range/primitives.d(2328): Attempting to fetch the front of an empty array of int The following code has no error: void main() { import

Re: scope(success) lowered to try-catch ?

2018-06-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 17 June 2018 at 10:58:29 UTC, Cauterite wrote: Hello, I'm not sure whether I'm missing something obvious here, but is there a reason for scope(success) being lowered to a try-catch statement? I would have expected only scope(exit) and scope(failure) to actually interact with

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

2018-06-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/16/18 6:23 PM, Jonathan M Davis wrote: I kind of wish that the forum software discouraged against necro-ing threads like this, since they're easy for many of us to miss, and once someone replies to them and brings them to the front of the list in the forum software, folks tends to reply as

Re: range.put() to Empty Array Causes Error?

2018-06-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/17/18 7:07 AM, Vijay Nayar wrote: This code breaks with the following error: void main() { import std.range;   int[] vals = []; vals.put(3); } /src/phobos/std/range/primitives.d(2328): Attempting to fetch the front of an empty array of int The following code has no error:

Re: scope(success) lowered to try-catch ?

2018-06-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/17/18 6:58 AM, Cauterite wrote: Hello, I'm not sure whether I'm missing something obvious here, but is there a reason for scope(success) being lowered to a try-catch statement? I would have expected only scope(exit) and scope(failure) to actually interact with exception handling, while

Re: scope(success) lowered to try-catch ?

2018-06-17 Thread Timoses via Digitalmars-d-learn
On Sunday, 17 June 2018 at 10:58:29 UTC, Cauterite wrote: Hello, I'm not sure whether I'm missing something obvious here, but is there a reason for scope(success) being lowered to a try-catch statement? I would have expected only scope(exit) and scope(failure) to actually interact with

Re: scope(success) lowered to try-catch ?

2018-06-17 Thread Cauterite via Digitalmars-d-learn
On Sunday, 17 June 2018 at 12:10:33 UTC, Nicholas Wilson wrote: I suspect scope(success) is lowered because scope(exit) and scope(failure) are, and that would result in a simpler (compiler) implementation of it. does adding nothrow to main fix it? For dcompute I specifically allow

Re: scope(success) lowered to try-catch ?

2018-06-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/17/18 8:24 AM, Timoses wrote: On Sunday, 17 June 2018 at 10:58:29 UTC, Cauterite wrote: Hello, I'm not sure whether I'm missing something obvious here, but is there a reason for scope(success) being lowered to a try-catch statement? I would have expected only scope(exit) and

Re: scope(success) lowered to try-catch ?

2018-06-17 Thread Mike Franklin via Digitalmars-d-learn
On Sunday, 17 June 2018 at 10:58:29 UTC, Cauterite wrote: --- // main.d void main() { scope(success) {} } dmd -betterC main.d Error: Cannot use try-catch statements with -betterC --- You can see what the compiler is doing at https://run.dlang.io/is/5BZOQV and clicking on the

Re: range.put() to Empty Array Causes Error?

2018-06-17 Thread Seb via Digitalmars-d-learn
On Sunday, 17 June 2018 at 12:23:55 UTC, Steven Schveighoffer wrote: On 6/17/18 7:07 AM, Vijay Nayar wrote: This code breaks with the following error: void main() { import std.range;   int[] vals = []; vals.put(3); } /src/phobos/std/range/primitives.d(2328): Attempting to fetch

scope(success) lowered to try-catch ?

2018-06-17 Thread Cauterite via Digitalmars-d-learn
Hello, I'm not sure whether I'm missing something obvious here, but is there a reason for scope(success) being lowered to a try-catch statement? I would have expected only scope(exit) and scope(failure) to actually interact with exception handling, while scope(success) simply places code on

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

2018-06-17 Thread Heromyth via Digitalmars-d-learn
On Sunday, 17 June 2018 at 20:03:09 UTC, aliak wrote: On Sunday, 17 June 2018 at 02:44:38 UTC, Heromyth wrote: [...] I think this bolts.isManifestAssignable [1] will get you partially there. The place where it'll fail though is a static immutable (since they are assignable to manifest

Re: scope(success) lowered to try-catch ?

2018-06-17 Thread Neia Neutuladh via Digitalmars-d-learn
On Sunday, 17 June 2018 at 10:58:29 UTC, Cauterite wrote: Is there a reason scope(success) needs to set up for exception handling? Or is this a bug / potential enhancement ? If you had no exception handling in place, you'd need to duplicate code in the output. For instance: void foo() {

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

2018-06-17 Thread aliak via Digitalmars-d-learn
On Sunday, 17 June 2018 at 02:44:38 UTC, Heromyth 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;

Re: typeof on protected field

2018-06-17 Thread DigitalDesigns via Digitalmars-d-learn
On Sunday, 17 June 2018 at 02:29:12 UTC, Adam D. Ruppe wrote: On Saturday, 16 June 2018 at 08:32:38 UTC, DigitalDesigns wrote: I need to get the protected and private members for serialization. This breaks encapsulation. A better design would be to have a class know how to serialize itself