Re: Explicitly avoid GC of objects?

2019-05-21 Thread Benjamin Schaaf via Digitalmars-d-learn
On Tuesday, 21 May 2019 at 11:54:08 UTC, Robert M. Münch wrote: Is there a trick to accomplish 2 when objects are created from different scopes which need to be kept? So, I have one function creating the objects and one using them. How can I keep things on the stack between these two

Re: "if" statement

2019-03-25 Thread Benjamin Schaaf via Digitalmars-d-learn
On Sunday, 24 March 2019 at 12:45:13 UTC, Francesco Mecca wrote: https://run.dlang.io/is/zRcj59 ``` alias Alg = Algebraic!(int, string); void main() { int n = 2; Alg value; value = n == 2 ? 2 : "string"; } ``` The original code used SumType but the effect is the same. I

Re: How to pass variables to string mixins?

2019-02-25 Thread Benjamin Schaaf via Digitalmars-d-learn
On Tuesday, 26 February 2019 at 00:07:54 UTC, Victor Porton wrote: I want to create a string mixin based on a supplementary variable (name2 below): Let we have something like: mixin template X(string name) { immutable string name2 = '_' ~ name; mixin("struct " ~ name2 ~ "{ int i; }"); }

Re: Disable dub from checking internet before building

2019-02-24 Thread Benjamin Schaaf via Digitalmars-d-learn
On Sunday, 24 February 2019 at 22:51:45 UTC, 0x wrote: How to disable dub from checking internet before building, it's slowing down build whenever it does this. Its not too well described but --nodeps skips dependency resolution (just uses the locked dependencies). Since dub only

Re: How to create a class-valued variable?

2019-02-19 Thread Benjamin Schaaf via Digitalmars-d-learn
On Tuesday, 19 February 2019 at 22:04:58 UTC, Victor Porton wrote: What is the right way to store in a structure a class (not an instance) derived from a given interface(s)? What are you trying to do with the "class"? If you just want a static "reference" to it you can use an `alias`:

Re: Should D file end with newline?

2019-02-10 Thread Benjamin Schaaf via Digitalmars-d-learn
On Sunday, 10 February 2019 at 02:12:43 UTC, Jonathan M Davis wrote: On Saturday, February 9, 2019 2:19:27 PM MST Victor Porton via Digitalmars- d-learn wrote: ISO C++ specifies that the C++ file must end with a newline. Should D file end with newline, too? No, there is no need to end D