Re: core.exception.InvalidMemoryOperationError

2014-07-10 Thread NCrashed via Digitalmars-d-learn
On Thursday, 10 July 2014 at 15:36:53 UTC, francesco cattoglio wrote: A code I'm working on stops working and starts printing an infinite loop of core.exception.InvalidMemoryOperationError to the command line output. The code is quite complex and the bug seems to present itself almost in random

Re: Introspecting a Module with Traits, allMembers

2014-07-09 Thread NCrashed via Digitalmars-d-learn
On Wednesday, 9 July 2014 at 20:07:57 UTC, NCrashed wrote: Produces: ir/iir.d(85): Error: argument has no members If module name is ir.iir: pragma(msg, __traits(allMembers, ir.iir));

Re: Introspecting a Module with Traits, allMembers

2014-07-09 Thread NCrashed via Digitalmars-d-learn
On Wednesday, 9 July 2014 at 20:04:47 UTC, Maxime Chevalier-Boisvert wrote: auto members = [__traits(allMembers, "ir.ir")]; pragma(msg, members); Have you tried without quotes? pragma(msg, __traits(allMembers, ir.ir));

Re: Small part of a program : d and c versions performances diff.

2014-07-09 Thread NCrashed via Digitalmars-d-learn
On Wednesday, 9 July 2014 at 10:57:33 UTC, Larry wrote: Hello, I extracted a part of my code written in c. it is deliberately useless here but I would understand the different technics to optimize such kind of code with gdc compiler. it currently runs under a microsecond. Constraint : the w

Re: Tuple and tie?

2014-07-08 Thread NCrashed via Digitalmars-d-learn
Sorry, some glitch with email answer. The main difference between my solution and TypeTuple is that you can pass anonymous struct between other functions to use it later: ``` void foo(T)(T holder) { holder = sinCos(3.0f); } void main() { float s,c; foo(tie(s,c));

Re: Tuple and tie?

2014-07-08 Thread NCrashed via Digitalmars-d-learn
On Tuesday, 8 July 2014 at 17:42:00 UTC, Remo wrote: How to make something that work like std::tie in D2 ? Tuple!(float, float) sinCos(float n) { return tuple(cast(float)sin(n), cast(float)cos(n)); //please note cast(float)! } int main(string[] argv) { float s,c; tie!(s,c) = sinCos(3.0f)

Re: Tuple and tie?

2014-07-08 Thread NCrashed . via Digitalmars-d-learn
Try this: ``` import std.typecons; import std.typetuple; import std.math; import std.stdio; auto tie(StoreElements...)(ref StoreElements stores) { alias Elements = staticMap!(Unqual, StoreElements); template toPointer(T) { alias toPointer = T*; } struct Holder { alias StoreElementsPtrs = staticM

Re: [dmd 2.066-b1] std.range.array with shared objects and AA rehash

2014-07-08 Thread NCrashed via Digitalmars-d-learn
On Tuesday, 8 July 2014 at 13:07:57 UTC, Meta wrote: On Tuesday, 8 July 2014 at 12:42:44 UTC, NCrashed wrote: Oops, I forgot shared at new. But the major issue is that doesn't fix the problem: ``` import std.range; class A {} InputRange!(shared A) foo() { return [new shared A].inputRa

Re: [dmd 2.066-b1] DList. Cannot remove from an un-initialized List

2014-07-08 Thread NCrashed via Digitalmars-d-learn
On Tuesday, 8 July 2014 at 13:06:34 UTC, NCrashed wrote: This was working under 2.065: ``` import std.container; void main() { DList!int list; list.clear(); } ``` Run-time assertion: ``` core.exception.AssertError@/usr/include/dmd/phobos/std/container/dlist.d(480): Cannot remov

[dmd 2.066-b1] DList. Cannot remove from an un-initialized List

2014-07-08 Thread NCrashed via Digitalmars-d-learn
This was working under 2.065: ``` import std.container; void main() { DList!int list; list.clear(); } ``` Run-time assertion: ``` core.exception.AssertError@/usr/include/dmd/phobos/std/container/dlist.d(480): Cannot remove from an un-initialized List /home/ncra

Re: [dmd 2.066-b1] std.range.array with shared objects and AA rehash

2014-07-08 Thread NCrashed via Digitalmars-d-learn
On Monday, 7 July 2014 at 15:34:33 UTC, Meta wrote: On Monday, 7 July 2014 at 09:53:22 UTC, NCrashed wrote: I am using ranges (wrapped in InputRangeObject for use in interfaces) of shared objects, with new beta some cases are broken: ``` import std.range; class A {} InputRange!(shared A) foo

[dmd 2.066-b1] std.range.array with shared objects and AA rehash

2014-07-07 Thread NCrashed via Digitalmars-d-learn
I am using ranges (wrapped in InputRangeObject for use in interfaces) of shared objects, with new beta some cases are broken: ``` import std.range; class A {} InputRange!(shared A) foo() { return [new A].inputRangeObject; } void bar() { auto res = foo.array; } void main() {}

Re: [dmd 2.066] Is scope with nothrow regression?

2014-07-06 Thread NCrashed via Digitalmars-d-learn
On Sunday, 6 July 2014 at 13:04:35 UTC, Marc Schütz wrote: On Sunday, 6 July 2014 at 12:31:42 UTC, NCrashed wrote: ``` void bar() { throw new Exception(""); } void foo() nothrow { scope(failure) {} bar(); } void main() {} ``` Doesn't compile with 2.066: ``` source/app.

[dmd 2.066] Is scope with nothrow regression?

2014-07-06 Thread NCrashed via Digitalmars-d-learn
``` void bar() { throw new Exception(""); } void foo() nothrow { scope(failure) {} bar(); } void main() {} ``` Doesn't compile with 2.066: ``` source/app.d(9): Error: 'app.bar' is not nothrow source/app.d(6): Error: function 'app.foo' is nothrow yet may throw ```