Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 17 November 2018 at 13:13:36 UTC, aliak wrote: On Friday, 16 November 2018 at 13:21:39 UTC, Stanislav Blinov wrote: auto assumeNoGC(T)(return scope T t) @trusted { /* ... */ } Sawweet! Thanks, that made the printing possible! "scope" is const from what I understand right? It

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-17 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 17 November 2018 at 13:13:36 UTC, aliak wrote: Sawweet! Thanks, that made the printing possible! You're welcome ;) Still, try a more recent compiler. This works fine: void foo() @nogc { debug { import std.stdio; writefln("%d", 42); } } "

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-17 Thread aliak via Digitalmars-d-learn
On Friday, 16 November 2018 at 13:03:40 UTC, Zoadian wrote: debug { import std.stdio; writeln(args); } As mentioned in the original post, that does not work.

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-17 Thread aliak via Digitalmars-d-learn
On Friday, 16 November 2018 at 13:21:39 UTC, Stanislav Blinov wrote: At 'point 1', you just take by value. If `t` ends up being a closure, D will allocate. That's where it breaks the @nogc. Solution: auto assumeNoGC(T)(return scope T t) { /* ... */ } Now you take (and return) a `scope` t

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-16 Thread ikod via Digitalmars-d-learn
On Friday, 16 November 2018 at 12:12:12 UTC, Alex wrote: = This code compiles as long as `lazy` is commented out. But I'd like to have both lazy parameter and @nogc inferrence for `library_func` so that user is not locked to code @nogc

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-16 Thread Stanislav Blinov via Digitalmars-d-learn
On Friday, 16 November 2018 at 12:59:22 UTC, aliak wrote: Adding @trusted to declaration of opDispatch gets rid of @safe error but I still get "Error: @nogc function D main cannot call non-@nogc function". And going through the codebase and figuring out where to add @truste

Re: How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-16 Thread Zoadian via Digitalmars-d-learn
debug { import std.stdio; writeln(args); }

How do you debug @safe @nogc code? Can't figure out how to print.

2018-11-16 Thread aliak via Digitalmars-d-learn
Hi, I previously had trouble trying to get print statements working while debugging in nogc. And that was hackishly solved [0], but I can't figure out how to do the same if I have @safe involved. Here's a cut down sample: // This is the function from the thread referenced auto assumeNoGC(T)(T

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-16 Thread Alex via Digitalmars-d-learn
On Friday, 16 November 2018 at 10:25:26 UTC, ikod wrote: On Thursday, 15 November 2018 at 21:55:18 UTC, Steven Schveighoffer wrote: On 11/15/18 4:09 PM, Adam D. Ruppe wrote: On Thursday, 15 November 2018 at 21:00:48 UTC, ikod wrote: what are the rules for @nogc inference? It attempts

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-16 Thread ikod via Digitalmars-d-learn
On Thursday, 15 November 2018 at 21:55:18 UTC, Steven Schveighoffer wrote: On 11/15/18 4:09 PM, Adam D. Ruppe wrote: On Thursday, 15 November 2018 at 21:00:48 UTC, ikod wrote: what are the rules for @nogc inference? It attempts it if and only if it is a template. Well, the general "

[Issue 19405] Speed up backwards UTF-8 decoding in stripRight & make nogc nothrow for strings

2018-11-16 Thread d-bugmail--- via Digitalmars-d-bugs
in stripRight & make nogc nothrow for strings https://github.com/dlang/phobos/commit/e6719075de7ba3ac9aa141325882bc98f30e1eaa Merge pull request #6771 from n8sh/issue-19405 Fix Issue 19405 - Speed up backwards UTF-8 decoding in stripRight & make nogc nothrow for strings --

[Issue 19405] Speed up backwards UTF-8 decoding in stripRight & make nogc nothrow for strings

2018-11-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=19405 github-bugzi...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED

[Issue 19405] Speed up backwards UTF-8 decoding in stripRight & make nogc nothrow for strings

2018-11-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=19405 --- Comment #1 from Nathan S. --- Pull request: https://github.com/dlang/phobos/pull/6771 --

[Issue 19405] Speed up backwards UTF-8 decoding in stripRight & make nogc nothrow for strings

2018-11-16 Thread d-bugmail--- via Digitalmars-d-bugs
|decoding in stripRight &|decoding in stripRight & |make nogc nothrow for |make nogc nothrow for |strings |strings --

[Issue 19405] Improve backwards UTF-8 decoding in stripRight & make nogc nothrow for strings

2018-11-16 Thread d-bugmail--- via Digitalmars-d-bugs
|decoding in stripRight |decoding in stripRight & ||make nogc nothrow for ||strings --

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/15/18 4:09 PM, Adam D. Ruppe wrote: On Thursday, 15 November 2018 at 21:00:48 UTC, ikod wrote: what are the rules for @nogc inference? It attempts it if and only if it is a template. Well, the general "rule" is, if it's code that must be available to the compiler when i

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 15 November 2018 at 21:00:48 UTC, ikod wrote: what are the rules for @nogc inference? It attempts it if and only if it is a template.

[Issue 19403] Make std.string.stripLeft on char array @nogc nothrow

2018-11-15 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=19403 --- Comment #1 from Nathan S. --- Pull request: https://github.com/dlang/phobos/pull/6769 --

[Issue 19403] Make std.string.stripLeft on char array @nogc nothrow

2018-11-15 Thread d-bugmail--- via Digitalmars-d-bugs
|char array could be @nogc |on char array @nogc nothrow |nothrow | --

[Issue 19403] New: std.string.stripLeft on char array could be @nogc nothrow

2018-11-15 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=19403 Issue ID: 19403 Summary: std.string.stripLeft on char array could be @nogc nothrow Product: D Version: D2 Hardware: All OS: All Status: NEW

Re: usable @nogc Exceptions with Mir Runtime

2018-11-02 Thread 9il via Digitalmars-d-announce
On Friday, 2 November 2018 at 07:00:49 UTC, Manu wrote: On Tue, Oct 30, 2018 at 9:30 AM Oleg via Digitalmars-d-announce wrote: Thanks for your work! > Example > === > /// > @safe pure nothrow @nogc > unittest > { > import mir.exception; &g

Re: usable @nogc Exceptions with Mir Runtime

2018-11-02 Thread Manu via Digitalmars-d-announce
On Tue, Oct 30, 2018 at 9:30 AM Oleg via Digitalmars-d-announce wrote: > > Thanks for your work! > > > Example > > === > > /// > > @safe pure nothrow @nogc > > unittest > > { > > import mir.exception; > > import

Re: usable @nogc Exceptions with Mir Runtime

2018-11-02 Thread bauss via Digitalmars-d-announce
On Friday, 2 November 2018 at 05:21:07 UTC, 9il wrote: On Thursday, 1 November 2018 at 10:17:25 UTC, bauss wrote: [...] Well, added at v0.0.8 [1]. Mir Runtime formatting and exceptions are CTFE-able if a msg fits into a local buffer and support user-defined types formatting. Note, that

Re: usable @nogc Exceptions with Mir Runtime

2018-11-01 Thread 9il via Digitalmars-d-announce
On Thursday, 1 November 2018 at 10:17:25 UTC, bauss wrote: On Wednesday, 31 October 2018 at 13:56:56 UTC, 9il wrote: ~ is used for string concatenation in D including string compile time constant concatenation. It is better not to override it because both << and ~ can be used in the same

Re: usable @nogc Exceptions with Mir Runtime

2018-11-01 Thread Atila Neves via Digitalmars-d-announce
append("Hi D", 2, "!", getData); Would have been a much better approach similar to how write/writeln etc. work from std.stdio. https://github.com/atilaneves/nogc/blob/ed4663558ceea1f5dc2634d6f01cc6ce6967adc1/tests/ut/exception.d#L49

Re: usable @nogc Exceptions with Mir Runtime

2018-11-01 Thread bauss via Digitalmars-d-announce
On Wednesday, 31 October 2018 at 13:56:56 UTC, 9il wrote: ~ is used for string concatenation in D including string compile time constant concatenation. It is better not to override it because both << and ~ can be used in the same expression. I see what your argument is now for it, BUT I

Re: usable @nogc Exceptions with Mir Runtime

2018-10-31 Thread Nathan S. via Digitalmars-d-announce
On Wednesday, 24 October 2018 at 10:57:27 UTC, 9il wrote: Release v0.0.5 comes with - mir.exception - @nogc MirException - mir.format - @nogc formatting Fantastic!

Re: usable @nogc Exceptions with Mir Runtime

2018-10-31 Thread 9il via Digitalmars-d-announce
On Wednesday, 31 October 2018 at 09:13:14 UTC, Uknown wrote: On Wednesday, 31 October 2018 at 08:34:08 UTC, 9il wrote: The C++ format style is simpler to implement and it is much faster to run. D's style came from C and Boost's format. Also, the C++ style is more low level then format strings,

Re: usable @nogc Exceptions with Mir Runtime

2018-10-31 Thread bauss via Digitalmars-d-announce
On Wednesday, 31 October 2018 at 09:13:14 UTC, Uknown wrote: On Wednesday, 31 October 2018 at 08:34:08 UTC, 9il wrote: The C++ format style is simpler to implement and it is much faster to run. D's style came from C and Boost's format. Also, the C++ style is more low level then format strings,

Re: usable @nogc Exceptions with Mir Runtime

2018-10-31 Thread Uknown via Digitalmars-d-announce
On Wednesday, 31 October 2018 at 08:34:08 UTC, 9il wrote: The C++ format style is simpler to implement and it is much faster to run. D's style came from C and Boost's format. Also, the C++ style is more low level then format strings, so they can be built on top of it. I think they meant why

Re: usable @nogc Exceptions with Mir Runtime

2018-10-31 Thread 9il via Digitalmars-d-announce
On Tuesday, 30 October 2018 at 16:25:12 UTC, Oleg wrote: Thanks for your work! Example === /// @safe pure nothrow @nogc unittest { import mir.exception; import mir.format; try throw new MirException(stringBuf() << "Hi D" << 2 <<

Re: usable @nogc Exceptions with Mir Runtime

2018-10-30 Thread Oleg via Digitalmars-d-announce
Thanks for your work! Example === /// @safe pure nothrow @nogc unittest { import mir.exception; import mir.format; try throw new MirException(stringBuf() << "Hi D" << 2 << "!" << getData);

[Issue 15598] core.atomicFence is not @nogc on x86

2018-10-27 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15598 Stanislav Blinov changed: What|Removed |Added Status|NEW |RESOLVED CC|

Re: Can opApply be made @nogc?

2018-10-21 Thread welkam via Digitalmars-d-learn
DIP 1000 says: Delegates currently defensively allocate closures with the GC. Few actually escape, and with scope only those that actually escape need to have the closures allocated. https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md#benefits

Re: Truly @nogc Exceptions?

2018-10-21 Thread welkam via Digitalmars-d
then scope "exits" trough scope(failure) in which case no deallocation should be performed and only if scope "exits" trough scope(success), meaning exception/s were handled, destructors need to be called. To make exceptions nogc we need destructors that are aware of how s

Re: Truly @nogc Exceptions?

2018-10-20 Thread Paolo Invernizzi via Digitalmars-d
On Saturday, 20 October 2018 at 14:56:37 UTC, Mike Parker wrote: On Saturday, 20 October 2018 at 13:48:32 UTC, Paolo Invernizzi wrote: If `@nogc` could be relaxed for `new Error` exactly for that reason, pieces of Phobos could be turned `@nogc`... But I admit that that change would

Re: Truly @nogc Exceptions?

2018-10-20 Thread Mike Parker via Digitalmars-d
On Saturday, 20 October 2018 at 13:48:32 UTC, Paolo Invernizzi wrote: If `@nogc` could be relaxed for `new Error` exactly for that reason, pieces of Phobos could be turned `@nogc`... But I admit that that change would be controversial... https://github.com/dlang/DIPs/blob/master/DIPs

Re: Truly @nogc Exceptions?

2018-10-20 Thread Paolo Invernizzi via Digitalmars-d
and throw the error you want ;) In my case, that's what I did anyway. I don't know how a performance problem can occur on an error being thrown anyway -- the process is about to end. -Steve If `@nogc` could be relaxed for `new Error` exactly for that reason, pieces of Phobos could be turned

Re: Truly @nogc Exceptions?

2018-10-19 Thread Atila Neves via Digitalmars-d
On Friday, 19 October 2018 at 23:46:29 UTC, Nicholas Wilson wrote: On Friday, 19 October 2018 at 23:34:01 UTC, Atila Neves wrote: On Thursday, 20 September 2018 at 12:48:13 UTC, Steven Schveighoffer wrote: How is the exception destroyed when dip1008 is enabled? Apparently, it isn't. Which

Re: Truly @nogc Exceptions?

2018-10-19 Thread Nicholas Wilson via Digitalmars-d
On Friday, 19 October 2018 at 23:34:01 UTC, Atila Neves wrote: On Thursday, 20 September 2018 at 12:48:13 UTC, Steven Schveighoffer wrote: How is the exception destroyed when dip1008 is enabled? Apparently, it isn't. Which renders dip1008 pretty much useless since we could already use static

Re: Can opApply be made @nogc?

2018-10-19 Thread Alex via Digitalmars-d-learn
On Friday, 19 October 2018 at 23:32:44 UTC, solidstate1991 wrote: Since it's a bit difficult to make tree traversal through range (especially if someone wants to make it @nogc), I thought I'll make it through opApply override, however the delegate passed by it doesn't have the @nogc attribute

Re: Can opApply be made @nogc?

2018-10-19 Thread rikki cattermole via Digitalmars-d-learn
On 20/10/2018 12:32 PM, solidstate1991 wrote: Since it's a bit difficult to make tree traversal through range (especially if someone wants to make it @nogc), I thought I'll make it through opApply override, however the delegate passed by it doesn't have the @nogc attribute, which would

Re: Truly @nogc Exceptions?

2018-10-19 Thread Atila Neves via Digitalmars-d
On Thursday, 20 September 2018 at 12:48:13 UTC, Steven Schveighoffer wrote: On 9/20/18 6:48 AM, Atila Neves wrote: On Wednesday, 19 September 2018 at 21:16:00 UTC, Steven Schveighoffer wrote: Given dip1008, we now can throw exceptions inside @nogc code! This is really cool, and helps make code

Can opApply be made @nogc?

2018-10-19 Thread solidstate1991 via Digitalmars-d-learn
Since it's a bit difficult to make tree traversal through range (especially if someone wants to make it @nogc), I thought I'll make it through opApply override, however the delegate passed by it doesn't have the @nogc attribute, which would automatically make it incapable to be used in a @nogc

[Issue 19311] Add @nogc attribute to Socket receive methods

2018-10-18 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=19311 Nathan S. changed: What|Removed |Added Summary|Add @nogc attribute to |Add @nogc attribute

[Issue 19311] New: Add @nogc attribute to std.socket receive methods

2018-10-18 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=19311 Issue ID: 19311 Summary: Add @nogc attribute to std.socket receive methods Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement

Re: Truly @nogc Exceptions?

2018-09-21 Thread Petar via Digitalmars-d
On Friday, 21 September 2018 at 11:48:50 UTC, Nemanja Boric wrote: On Friday, 21 September 2018 at 10:06:06 UTC, Nemanja Boric wrote: On Friday, 21 September 2018 at 09:10:06 UTC, Jonathan M Davis wrote: [...] The @__future is fully (to a reasonable degree) implemented - and the

Re: Truly @nogc Exceptions?

2018-09-21 Thread Nemanja Boric via Digitalmars-d
On Friday, 21 September 2018 at 10:06:06 UTC, Nemanja Boric wrote: On Friday, 21 September 2018 at 09:10:06 UTC, Jonathan M Davis wrote: [...] The @__future is fully (to a reasonable degree) implemented - and the `Throwable.message` was marked with this attribute to prevent breaking the

Re: Truly @nogc Exceptions?

2018-09-21 Thread Nemanja Boric via Digitalmars-d
On Friday, 21 September 2018 at 09:10:06 UTC, Jonathan M Davis wrote: [...] I think that the message member was added by Dicebot as an attempt to fix this issue, because Sociomantic needed it, but I don't know exactly what's going on with that or @__future. - Jonathan M Davis The @__future

Re: Truly @nogc Exceptions?

2018-09-21 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, September 19, 2018 3:16:00 PM MDT Steven Schveighoffer via Digitalmars-d wrote: > Given dip1008, we now can throw exceptions inside @nogc code! This is > really cool, and helps make code that uses exceptions or errors @nogc. > Except... I pointed out this problem whe

Re: Truly @nogc Exceptions?

2018-09-20 Thread Steven Schveighoffer via Digitalmars-d
On 9/20/18 1:58 PM, Adam D. Ruppe wrote: On Thursday, 20 September 2018 at 17:14:12 UTC, Steven Schveighoffer wrote: I don't know how a performance problem can occur on an error being thrown anyway -- the process is about to end. Walter's objection was code size - it would throw stuff out of

Re: Truly @nogc Exceptions?

2018-09-20 Thread Neia Neutuladh via Digitalmars-d
don't ever have to allocate unless the sink itself does. I believe Tango did this a decade ago. It's a solid strategy. However, with Tango, the default was to implement the toString(sink) function by calling the regular toString(), which was quite convenient but won't work with @nogc.

Re: Truly @nogc Exceptions?

2018-09-20 Thread Adam D. Ruppe via Digitalmars-d
On Thursday, 20 September 2018 at 17:14:12 UTC, Steven Schveighoffer wrote: I don't know how a performance problem can occur on an error being thrown anyway -- the process is about to end. Walter's objection was code size - it would throw stuff out of cache lines, even if it doesn't need to

Re: Truly @nogc Exceptions?

2018-09-20 Thread Steven Schveighoffer via Digitalmars-d
On 9/20/18 12:24 PM, Adam D. Ruppe wrote: On Thursday, 20 September 2018 at 15:52:03 UTC, Steven Schveighoffer wrote: I needed to know what the slice parameters that were failing were. Aye. Note that RangeError is called by the compiler though, so you gotta patch dmd to make it pass the

Re: Truly @nogc Exceptions?

2018-09-20 Thread Adam D. Ruppe via Digitalmars-d
On Thursday, 20 September 2018 at 15:52:03 UTC, Steven Schveighoffer wrote: I needed to know what the slice parameters that were failing were. Aye. Note that RangeError is called by the compiler though, so you gotta patch dmd to make it pass the arguments to it for index. Ugh. I did a PR for

Re: Truly @nogc Exceptions?

2018-09-20 Thread Steven Schveighoffer via Digitalmars-d
ed     filename = nofile.txt     mode = rb Awesome! This is just what I was thinking of. In fact, I did something similar locally since I needed to know what the slice parameters that were failing were. I still had to trick the @nogc to get around the &q

Re: Truly @nogc Exceptions?

2018-09-20 Thread H. S. Teoh via Digitalmars-d
catcher asks for it. And if the catcher doesn't ask for it, we saved > > an extra GC allocation (which is a plus even if we're not trying to > > go @nogc). > > Except we DON'T construct the stack trace string, even lazily. If you > look at the code I posted, it's output dire

Re: Truly @nogc Exceptions?

2018-09-20 Thread Adam D. Ruppe via Digitalmars-d
On Wednesday, 19 September 2018 at 21:16:00 UTC, Steven Schveighoffer wrote: As Andrei says -- Destroy! Nah, I agree. Actually, I'm of the opinion that string error messages in exceptions ought to be considered harmful: you shouldn't be doing strings at all. All the useful information

Re: Truly @nogc Exceptions?

2018-09-20 Thread Steven Schveighoffer via Digitalmars-d
the catcher asks for it. And if the catcher doesn't ask for it, we saved an extra GC allocation (which is a plus even if we're not trying to go @nogc). Except we DON'T construct the stack trace string, even lazily. If you look at the code I posted, it's output directly to the output buffer (via

Re: Truly @nogc Exceptions?

2018-09-20 Thread H. S. Teoh via Digitalmars-d
n the catcher asks for it. And if the catcher doesn't ask for it, we saved an extra GC allocation (which is a plus even if we're not trying to go @nogc). T -- Computers shouldn't beep through the keyhole.

Re: Truly @nogc Exceptions?

2018-09-20 Thread Atila Neves via Digitalmars-d
it to RAII managed memory and you're good to go. Give me deterministic destruction of exceptions caught by scope when using dip1008 and I'll give you @nogc exception throwing immediately. I've even already written the code! I thought it already did that? How is the exception destroyed when

Re: Small @nogc experience report

2018-09-20 Thread Seb via Digitalmars-d
already if only I'd known @nogc was ignored as well as pure. It's a recent development: https://dlang.org/changelog/2.082.0#debug-unsafe : Unsafe code can now be used in debug blocks https://dlang.org/changelog/2.079.0 : Bugzilla 16492: support @nogc in debug{} blocks Ah. I was wondering

Re: Small @nogc experience report

2018-09-20 Thread Atila Neves via Digitalmars-d
On Thursday, 20 September 2018 at 12:41:07 UTC, Petar Kirov [ZombineDev] wrote: On Thursday, 20 September 2018 at 10:50:49 UTC, Atila Neves wrote: This pattern is incredibly easy to wrap and reuse as needed. I would've done already if only I'd known @nogc was ignored as well as pure. It's

Re: Truly @nogc Exceptions?

2018-09-20 Thread Steven Schveighoffer via Digitalmars-d
On 9/20/18 6:48 AM, Atila Neves wrote: On Wednesday, 19 September 2018 at 21:16:00 UTC, Steven Schveighoffer wrote: Given dip1008, we now can throw exceptions inside @nogc code! This is really cool, and helps make code that uses exceptions or errors @nogc. Except... The mechanism to report

Re: Small @nogc experience report

2018-09-20 Thread Petar via Digitalmars-d
On Thursday, 20 September 2018 at 10:50:49 UTC, Atila Neves wrote: This pattern is incredibly easy to wrap and reuse as needed. I would've done already if only I'd known @nogc was ignored as well as pure. It's a recent development: https://dlang.org/changelog/2.082.0#debug-unsafe : Unsafe

Re: Small @nogc experience report

2018-09-20 Thread Atila Neves via Digitalmars-d
, arg)); // No good - format is not @nogc Another method:   debug     assert(condition, format(string, arg, arg));   else     assert(condition, string); because @nogc is ignored in debug conditionals, just like purity is ignored in debug conditionals. That doesn't cut it on so many levels

Re: Truly @nogc Exceptions?

2018-09-20 Thread Atila Neves via Digitalmars-d
On Wednesday, 19 September 2018 at 21:16:00 UTC, Steven Schveighoffer wrote: Given dip1008, we now can throw exceptions inside @nogc code! This is really cool, and helps make code that uses exceptions or errors @nogc. Except... The mechanism to report what actually went wrong

Re: Small @nogc experience report

2018-09-19 Thread Shachar Shemesh via Digitalmars-d
On 19/09/18 22:53, Walter Bright wrote: On 9/19/2018 10:13 AM, Shachar Shemesh wrote:    assert(condition, string); // string is useless without actual info about what went wrong.    assert(condition, format(string, arg, arg)); // No good - format is not @nogc Another method:   debug

Re: Truly @nogc Exceptions?

2018-09-19 Thread Steven Schveighoffer via Digitalmars-d
On 9/19/18 7:53 PM, Seb wrote: On Wednesday, 19 September 2018 at 21:28:56 UTC, Steven Schveighoffer wrote: On 9/19/18 5:16 PM, Steven Schveighoffer wrote: One further thing: I didn't make the sink version of message @nogc, but in actuality, it could be. We recently introduced support

Re: Truly @nogc Exceptions?

2018-09-19 Thread Seb via Digitalmars-d
On Wednesday, 19 September 2018 at 21:28:56 UTC, Steven Schveighoffer wrote: On 9/19/18 5:16 PM, Steven Schveighoffer wrote: One further thing: I didn't make the sink version of message @nogc, but in actuality, it could be. We recently introduced support for output ranges in the formatting

Re: Truly @nogc Exceptions?

2018-09-19 Thread Steven Schveighoffer via Digitalmars-d
On 9/19/18 5:16 PM, Steven Schveighoffer wrote: One further thing: I didn't make the sink version of message @nogc, but in actuality, it could be. Notice how it allocates using the stack. Even if we needed some indeterminate amount of memory, it would be simple to use C malloc/free, or alloca

Truly @nogc Exceptions?

2018-09-19 Thread Steven Schveighoffer via Digitalmars-d
Given dip1008, we now can throw exceptions inside @nogc code! This is really cool, and helps make code that uses exceptions or errors @nogc. Except... The mechanism to report what actually went wrong for an exception is a string passed to the exception during *construction*. Given that you

Re: Small @nogc experience report

2018-09-19 Thread Walter Bright via Digitalmars-d
On 9/19/2018 11:35 AM, Steven Schveighoffer wrote: I'm running into this coincidentally right now, when trying to debug a PR. I found I'm getting a range error deep inside a phobos function. But because Phobos is trying to be pure @nogc nothrow @safe, I can do almost nothing to display what

Re: Small @nogc experience report

2018-09-19 Thread Walter Bright via Digitalmars-d
On 9/19/2018 10:13 AM, Shachar Shemesh wrote:   assert(condition, string); // string is useless without actual info about what went wrong.   assert(condition, format(string, arg, arg)); // No good - format is not @nogc Another method: debug assert(condition, format(string, arg, arg

Re: Small @nogc experience report

2018-09-19 Thread Walter Bright via Digitalmars-d
On 9/7/2018 10:35 AM, Eugene Wissner wrote: fill() uses enforce() which allocates and throws. The addition of -dip1008 stopped using the gc for throwing exceptions, but it's opt-in at the moment.

Re: Small @nogc experience report

2018-09-19 Thread Shachar Shemesh via Digitalmars-d
On 19/09/18 21:35, Steven Schveighoffer wrote: On 9/19/18 1:13 PM, Shachar Shemesh wrote: There is a catch, though. Writing Mecca with @nogc required re-implementing quite a bit of druntime. Mecca uses its own exception allocations (mkEx, just saw it's not yet documented, it's under

Re: Small @nogc experience report

2018-09-19 Thread Steven Schveighoffer via Digitalmars-d
On 9/19/18 1:13 PM, Shachar Shemesh wrote: There is a catch, though. Writing Mecca with @nogc required re-implementing quite a bit of druntime. Mecca uses its own exception allocations (mkEx, just saw it's not yet documented, it's under mecca.lib.exception). The same module also has

Re: Small @nogc experience report

2018-09-19 Thread Shachar Shemesh via Digitalmars-d
On 08/09/18 11:07, Peter Alexander wrote: I'd love to know if anyone is making good use of @nogc in a larger code base and is happy with it. Weka.io? No, sorry. Actually, yes. Well, sortof. The main Weka codebase hardly uses any annotations of any kind. Not @nogc nor others

Re: Small @nogc experience report

2018-09-19 Thread Shachar Shemesh via Digitalmars-d
and wanted to make sure everything continued working before all GC allocations were removed. mecca.lib.reflection has "as". https://weka-io.github.io/mecca/docs/mecca/lib/reflection/as.html Here is how you use it: void fun() @nogc { as!"@nogc"( some code that is not @no

Re: Small @nogc experience report

2018-09-19 Thread Per Nordlöw via Digitalmars-d
On Friday, 7 September 2018 at 17:01:09 UTC, Meta wrote: So it seems that it's never worked. Looking at the implementation, it uses a std.container.BinaryHeap, so it'd require a small rewrite to work with @nogc. AFAICT, extending std.container with support for specifying you own @nogc

Re: Small @nogc experience report

2018-09-11 Thread Guillaume Piolat via Digitalmars-d
On Monday, 10 September 2018 at 09:11:38 UTC, Kagamin wrote: On Saturday, 8 September 2018 at 08:32:58 UTC, Guillaume Piolat wrote: There is no other choice when the runtime is disabled but to have @nogc. It's a fantastic peace of mind for high-performance to be able to _enforce_ something

Re: Small @nogc experience report

2018-09-11 Thread Dukc via Digitalmars-d
On Saturday, 8 September 2018 at 08:32:58 UTC, Guillaume Piolat wrote: Not Weka but we are happy with @nogc and without @nogc our job would be impossible. There is one way to code without garbage collector somewhat practically without annotating @nogc, the way I use: Compile manually only

Re: Small @nogc experience report

2018-09-10 Thread rikki cattermole via Digitalmars-d
On 10/09/2018 9:11 PM, Kagamin wrote: On Saturday, 8 September 2018 at 08:32:58 UTC, Guillaume Piolat wrote: There is no other choice when the runtime is disabled but to have @nogc. It's a fantastic peace of mind for high-performance to be able to _enforce_ something will not allocate. You

Re: Small @nogc experience report

2018-09-10 Thread Kagamin via Digitalmars-d
On Saturday, 8 September 2018 at 08:32:58 UTC, Guillaume Piolat wrote: There is no other choice when the runtime is disabled but to have @nogc. It's a fantastic peace of mind for high-performance to be able to _enforce_ something will not allocate. You can't have a working GC allocation

Re: Small @nogc experience report

2018-09-08 Thread Peter Alexander via Digitalmars-d
On Saturday, 8 September 2018 at 08:32:58 UTC, Guillaume Piolat wrote: On Saturday, 8 September 2018 at 08:07:07 UTC, Peter Alexander wrote: I'd love to know if anyone is making good use of @nogc in a larger code base and is happy with it. Weka.io? Not Weka but we are happy with @nogc

Re: Small @nogc experience report

2018-09-08 Thread Guillaume Piolat via Digitalmars-d
On Saturday, 8 September 2018 at 08:07:07 UTC, Peter Alexander wrote: I'd love to know if anyone is making good use of @nogc in a larger code base and is happy with it. Weka.io? Not Weka but we are happy with @nogc and without @nogc our job would be impossible. You don't like it fine. But I

Re: Small @nogc experience report

2018-09-08 Thread Peter Alexander via Digitalmars-d
On Friday, 7 September 2018 at 17:01:09 UTC, Meta wrote: You are allowed to call "@gc" functions inside @nogc functions if you prefix them with a debug statement, e.g.: Thanks! I was aware that debug is an escape hatch for pure, but didn't consider it for @nogc. I've been think

Re: Small @nogc experience report

2018-09-07 Thread Meta via Digitalmars-d
(?) is @nogc, so he either missed topNCopy or the gc-ness of the function has changed sometime between ~2015 and now. It was never true. Here is another example: import std.algorithm; void main() @nogc { int[4] a, b; fill(a[], b[]); } The funny thing is that fill() doesn't always allocate

Re: Small @nogc experience report

2018-09-07 Thread Eugene Wissner via Digitalmars-d
On Friday, 7 September 2018 at 16:44:05 UTC, Peter Alexander wrote: I recently wrote a small program of ~600 lines of code to solve an optimisation puzzle. Profiling showed that GC allocations were using non-trivial CPU, so I decided to try and apply @nogc to remove allocations

Re: Small @nogc experience report

2018-09-07 Thread Eugene Wissner via Digitalmars-d
On Friday, 7 September 2018 at 17:01:09 UTC, Meta wrote: Semi-unrelated, but I think you should open a bug for this one. I remember Andrei stating before that every function in std.algorithm except for LevehnsteinDistance(?) is @nogc, so he either missed topNCopy or the gc-ness of the function

Re: Small @nogc experience report

2018-09-07 Thread H. S. Teoh via Digitalmars-d
On Fri, Sep 07, 2018 at 04:44:05PM +, Peter Alexander via Digitalmars-d wrote: > I recently wrote a small program of ~600 lines of code to solve an > optimisation puzzle. Profiling showed that GC allocations were using > non-trivial CPU, so I decided to try and apply @nogc

Re: Small @nogc experience report

2018-09-07 Thread Meta via Digitalmars-d
On Friday, 7 September 2018 at 16:44:05 UTC, Peter Alexander wrote: I recently wrote a small program of ~600 lines of code to solve an optimisation puzzle. Profiling showed that GC allocations were using non-trivial CPU, so I decided to try and apply @nogc to remove allocations

Small @nogc experience report

2018-09-07 Thread Peter Alexander via Digitalmars-d
I recently wrote a small program of ~600 lines of code to solve an optimisation puzzle. Profiling showed that GC allocations were using non-trivial CPU, so I decided to try and apply @nogc to remove allocations. This is a small experience report of my efforts. 1. My program does some

Re: D's policy on hidden memory allocations and nothrow @nogc

2018-09-05 Thread Per Nordlöw via Digitalmars-d
On Wednesday, 5 September 2018 at 21:06:07 UTC, Adam D. Ruppe wrote: It doesn't affect @nogc because the function above will throw a statically-allocated object instead of creating a new one (if it is out of memory, where would it allocate a new one anyway?). It doesn't affect nothrow because

Re: D's policy on hidden memory allocations and nothrow @nogc

2018-09-05 Thread Adam D. Ruppe via Digitalmars-d
ry be non-`nothrow`, and in turn, non-`@nogc`? No, it doesn't affect either of those. It doesn't affect @nogc because the function above will throw a statically-allocated object instead of creating a new one (if it is out of memory, where would it allocate a new one anyway?). It doesn't affe

D's policy on hidden memory allocations and nothrow @nogc

2018-09-05 Thread Per Nordlöw via Digitalmars-d
error? If so should all algorithms that potentially allocates memory be non-`nothrow`, and in turn, non-`@nogc`? And how does this relate to instead using `assert`s and DIP-1008? [1]: https://ziglang.org/

Re: anyway to debug nogc code with writeln?

2018-09-03 Thread aliak via Digitalmars-d-learn
) { enum attrs = functionAttributes!T | FunctionAttribute.nogc; return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) t; } void f(T)(auto ref T) { writeln("yo"); } @nogc void main() { assumeNoGC(() => f(3)); // or assumeNoGC( { writeln("yo&

Re: anyway to debug nogc code with writeln?

2018-09-02 Thread Dennis via Digitalmars-d-learn
On Saturday, 1 September 2018 at 21:53:03 UTC, aliak wrote: Anyway around this? I don't know if your situation allows it, but you can mark f explicitly as always @nogc. If your design assumes that it's @nogc, it's a good idea to add the attribute anyway. You can also use the C printf

Re: anyway to debug nogc code with writeln?

2018-09-01 Thread Ali Çehreli via Digitalmars-d-learn
; return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) t; } void f(T)(auto ref T) { writeln("yo"); } @nogc void main() { assumeNoGC(() => f(3)); // or assumeNoGC( { writeln("yo"); }); } Ali

anyway to debug nogc code with writeln?

2018-09-01 Thread aliak via Digitalmars-d-learn
I would like to debug a few things and need to insert print statements to figure things out. I thought that using debug print would be ok in nogc code? Seems it make the compiler infer f as not nogc though so this is basically unworkable unless I go through my entire source code and remove

<    1   2   3   4   5   6   7   8   9   10   >