Re: debug public release private

2016-07-24 Thread Cauterite via Digitalmars-d-learn
On Monday, 25 July 2016 at 04:58:55 UTC, Gorge Jingale wrote: debug mixin("public"); else mixin("private"); Perhaps you could build a patched DMD which ignores 'private'. Then when you want to compile with -debug, use this custom DMD, and use the standard DMD the rest of the time. I imagine

Re: Static ternary if

2016-07-24 Thread Ali Çehreli via Digitalmars-d-learn
On 07/24/2016 07:15 PM, Gorge Jingale wrote: Is there a static ternary if? (A == B) ? C : D; for compile type that works like static if. The way to force an expression at compile time is to use it for something that's needed at compile time. For example, you can initialize a manifest consta

debug public release private

2016-07-24 Thread Gorge Jingale via Digitalmars-d-learn
debug mixin("public"); else mixin("private"); Doesn't work. It's nice to have public members when debugging because they show up in the debugger and one can access internals for checking. One can enable per line using debug but it requires lots of duplicate code. Is there any easy way to d

Re: Randomized unittests

2016-07-24 Thread Gorge Jingale via Digitalmars-d-learn
On Monday, 25 July 2016 at 02:36:04 UTC, Chris Wright wrote: On Mon, 25 Jul 2016 01:49:25 +, Gorge Jingale wrote: [...] http://code.dlang.org/packages/unit-threaded @Values() annotation on a unittest takes a range. Base that on a range that yields random values and Bob's your uncle. T

Re: Randomized unittests

2016-07-24 Thread Chris Wright via Digitalmars-d-learn
On Mon, 25 Jul 2016 01:49:25 +, Gorge Jingale wrote: > Is there any leverage in the D library for doing randomized unit > testing? Testing things with a range of possibilities instead of fixed. > Each time the test is ran a different version is executed. > This provides more coverage. > > How

Static ternary if

2016-07-24 Thread Gorge Jingale via Digitalmars-d-learn
Is there a static ternary if? (A == B) ? C : D; for compile type that works like static if.

Randomized unittests

2016-07-24 Thread Gorge Jingale via Digitalmars-d-learn
Is there any leverage in the D library for doing randomized unit testing? Testing things with a range of possibilities instead of fixed. Each time the test is ran a different version is executed. This provides more coverage. How does one create a random number at compile time? Is this the onl

Re: mixin template hide

2016-07-24 Thread arturg via Digitalmars-d-learn
On Sunday, 24 July 2016 at 18:38:53 UTC, Eppason wrote: The obvious solution is to refactor Bar, but in the real world, it is much harder and life would be much easier if I could remove foo from exists inside S. At worse, if Bar did depend on foo, I would simply get errors about missing foo.

mixin template hide

2016-07-24 Thread Eppason via Digitalmars-d-learn
I use self-introspection and have the case for having to "remove" things from the mixin. Typically the mixin will mixin stuff that it does not exist in the scope it is trying to mix in, a great feature. But what I would like to do is tell the mixin not to mix in foo(), this allows me to take

Re: Transform/Compile to C/CPP as a target

2016-07-24 Thread ParticlePeter via Digitalmars-d-learn
On Saturday, 23 July 2016 at 19:20:10 UTC, Jacob Carlborg wrote: On 2016-07-23 14:27, ParticlePeter wrote: Is there any kind of project or workflow that converts D (subset) to C/CPP ? No idea about the status but: https://github.com/adamdruppe/tools/blob/dtoh/dtoh.d Thanks, I am looking in

Calling methods under gdb.

2016-07-24 Thread ANtlord via Digitalmars-d-learn
Hello everyone! I want to contribute some project, but I have inconvenient things related to debug. My high level of using GDB is show a variable and get type of a variable. In C++ usually I use QtCreator and debugging was pretty. In Python I have PDB, that can evaluate code. In D I have just

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 24 July 2016 at 15:41:55 UTC, Lodovico Giaretta wrote: On Sunday, 24 July 2016 at 15:28:53 UTC, Jonathan Marler wrote: Whoa wait a second...I didn't know you could do this. I thought everything had to inherit from the object class. Can you share the syntax to define a class that do

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Lodovico Giaretta via Digitalmars-d-learn
On Sunday, 24 July 2016 at 15:31:28 UTC, lqjglkqjsg wrote: Almost off topic but I've recognized a typical error here, I think that many of us have already seen it too. You develop a nice class. You put attributes everywhere @safe pure nothrow @nogc. Yay the unittest pass. Later you use it for

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Lodovico Giaretta via Digitalmars-d-learn
On Sunday, 24 July 2016 at 15:28:53 UTC, Jonathan Marler wrote: Whoa wait a second...I didn't know you could do this. I thought everything had to inherit from the object class. Can you share the syntax to define a class that doesn't derive from object? Currently, you cannot. Everything inhe

Re: Singletons importing each other?

2016-07-24 Thread lqjglkqjsg via Digitalmars-d-learn
On Sunday, 24 July 2016 at 15:07:20 UTC, Jack wrote: Is there a way for singletons that import each other, use each other's functions? Like i.e: -- module sing1; import sing2; final class Singleton_1{ static this{ instance = new Singleton_1(); } static Singleton_1 getInstance(){ return i

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread lqjglkqjsg via Digitalmars-d-learn
On Sunday, 24 July 2016 at 15:09:53 UTC, Lodovico Giaretta wrote: Yes, making them @nogc would require all existing overrides to be changed (overrides cannot throw away attributes, but must specify them explicitly as in the parent class, or stricter). The real problem making these @nogc is that

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 24 July 2016 at 15:09:53 UTC, Lodovico Giaretta wrote: Remember that comparison of complex objects may require normalization, which may change the objects themselves and allocate memory. Sure but this case will be the exception. If an application really needs this they can impleme

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Lodovico Giaretta via Digitalmars-d-learn
On Sunday, 24 July 2016 at 14:54:11 UTC, Jonathan Marler wrote: I believe Rufus was only referring to the virtual methods defined in the object class. That would be: toHash (Note: this is already nothrow, that's intersting and quite restrictive) opCmp opEquals I think all 3 of these are goo

Singletons importing each other?

2016-07-24 Thread Jack via Digitalmars-d-learn
Is there a way for singletons that import each other, use each other's functions? Like i.e: -- module sing1; import sing2; final class Singleton_1{ static this{ instance = new Singleton_1(); } static Singleton_1 getInstance(){ return instance; } void foo(){ writeln("Sample"); } void bar

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 24 July 2016 at 09:03:04 UTC, Lodovico Giaretta wrote: On Sunday, 24 July 2016 at 02:17:27 UTC, Rufus Smith wrote: [...] Now you are telling me to "program by trust", because there's nothing ensuring that I remember to free everything I allocated with malloc/free, while a GC would

Re: Modules

2016-07-24 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 24 July 2016 at 02:45:57 UTC, rikki cattermole wrote: On 24/07/2016 2:28 PM, Rufus Smith wrote: NM, ignore. Seems it was something else going on. Although, if you know how how dmd resolves this stuff exactly, it would be nice to know. Does it just use the module names regardless of p

Re: Expression template

2016-07-24 Thread Ilya Yaroshenko via Digitalmars-d-learn
On Saturday, 23 July 2016 at 11:05:57 UTC, Etranger wrote: 1- Is there a cleaner way to do it ? I had to use struct because I want every thing to happen at compile time and on the stack (without gc). And I had to use string mixins because template mixin does not work the way I tried to use it

Re: extract .manglof of template with lambda parameters

2016-07-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 24 July 2016 at 06:03:59 UTC, Nicholas Wilson wrote: so I have a main as follows int main(string[] args) { int a = 3; map!((int x) => x*x)((GlobalPointer!int(&a)),a); return 0; } I want to get the mangleof of the generated call to map but without referencing it in the .o

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Lodovico Giaretta via Digitalmars-d-learn
On Sunday, 24 July 2016 at 02:17:27 UTC, Rufus Smith wrote: This just isn't right. What your saying is that because someone screwed up, we must live with the screw up and build everyone around the screw up. This mentality is why everyone is so screwed up in the first place, do you not see that?

Re: Default implementations in inherited interfaces

2016-07-24 Thread Antonio Corbi via Digitalmars-d-learn
On Sunday, 24 July 2016 at 07:54:11 UTC, Jonathan Marler wrote: On Thursday, 21 July 2016 at 13:37:30 UTC, Saurabh Das wrote: On Thursday, 21 July 2016 at 12:42:14 UTC, Adam D. Ruppe wrote: On Thursday, 21 July 2016 at 09:41:27 UTC, Saurabh Das wrote: Java 8 has a 'default' keyword that allows

Re: Default implementations in inherited interfaces

2016-07-24 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 21 July 2016 at 13:37:30 UTC, Saurabh Das wrote: On Thursday, 21 July 2016 at 12:42:14 UTC, Adam D. Ruppe wrote: On Thursday, 21 July 2016 at 09:41:27 UTC, Saurabh Das wrote: Java 8 has a 'default' keyword that allows interfaces to provide a default implementation and sub-classes c