Re: trick to make throwing method @nogc

2017-02-26 Thread Guest via Digitalmars-d-learn
On Saturday, 25 February 2017 at 19:59:29 UTC, ikod wrote: Hello, I have a method for range: struct Range { immutable(ubyte[]) _buffer; size_t _pos; @property void popFront() pure @safe { enforce(_pos < _buffer.length, "popFront from empty buffer");

Re: trick to make throwing method @nogc

2017-02-25 Thread Profile Anaysis via Digitalmars-d-learn
On Saturday, 25 February 2017 at 19:59:29 UTC, ikod wrote: Hello, I have a method for range: struct Range { immutable(ubyte[]) _buffer; size_t _pos; @property void popFront() pure @safe { enforce(_pos < _buffer.length, "popFront from empty buffer");

Re: trick to make throwing method @nogc

2017-02-25 Thread ikod via Digitalmars-d-learn
On Saturday, 25 February 2017 at 20:49:51 UTC, Adam D. Ruppe wrote: A wrapper that unifies these 4 steps like enforce is pretty easy to implement. yeah easy to use exception in @nogc as long as the catch knows to free it too. Alas, not my case. Exception can be catched not in my code.

Re: trick to make throwing method @nogc

2017-02-25 Thread Eugene Wissner via Digitalmars-d-learn
On Saturday, 25 February 2017 at 20:49:51 UTC, Adam D. Ruppe wrote: On Saturday, 25 February 2017 at 20:40:26 UTC, Eugene Wissner wrote: it builds and doesn't throw if I compile with: dmd -release though it causes a segfault, what is probably a dmd bug. No, that's by design. assert(0)

Re: trick to make throwing method @nogc

2017-02-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 25 February 2017 at 20:40:26 UTC, Eugene Wissner wrote: it builds and doesn't throw if I compile with: dmd -release though it causes a segfault, what is probably a dmd bug. No, that's by design. assert(0) compiles to a segfault instruction with -release. A wrapper that unifies

Re: trick to make throwing method @nogc

2017-02-25 Thread Eugene Wissner via Digitalmars-d-learn
On Saturday, 25 February 2017 at 20:02:56 UTC, ikod wrote: On Saturday, 25 February 2017 at 19:59:29 UTC, ikod wrote: Hello, I have a method for range: struct Range { immutable(ubyte[]) _buffer; size_t _pos; @property void popFront() pure @safe { enforce(_pos

Re: trick to make throwing method @nogc

2017-02-25 Thread ikod via Digitalmars-d-learn
On Saturday, 25 February 2017 at 19:59:29 UTC, ikod wrote: Hello, I have a method for range: struct Range { immutable(ubyte[]) _buffer; size_t _pos; @property void popFront() pure @safe { enforce(_pos < _buffer.length, "popFront from empty buffer");