On Friday, 13 February 2015 at 19:03:10 UTC, Jonathan Marler
wrote:
This question comes from wanting to be able to throw an
exception in code that is @nogc.
https://dlang.org/changelog/2.079.0.html#dip1008
```d
void main() @nogc
{
throw new Exception("I'm @nogc now");
}
```
On Wednesday, 13 July 2016 at 22:42:36 UTC, Adam Sansier wrote:
On Wednesday, 13 July 2016 at 21:27:16 UTC, Lodovico Giaretta
wrote:
At the end, all memory comes from one of these: GC heap,
malloc, mmap, sbrk. All other allocators build on top of these
(or on top of user supplied buffers,
On Wednesday, 13 July 2016 at 21:27:16 UTC, Lodovico Giaretta
wrote:
On Wednesday, 13 July 2016 at 21:12:29 UTC, Adam Sansier wrote:
[...]
Ok, I like!
[...]
I like too! But I'll have to assume you are right since I have
no proof.
[...]
Well, one could do this with malloc because one
On Wednesday, 13 July 2016 at 21:12:29 UTC, Adam Sansier wrote:
The advantages over a simple malloc are:
1) You can change between GC allocation, malloc, mmap and
other allocators by changing a single line, instead of
changing every throw;
Ok, I like!
2) you can use very fast allocators,
On Wednesday, 13 July 2016 at 20:57:49 UTC, Lodovico Giaretta
wrote:
On Wednesday, 13 July 2016 at 20:44:52 UTC, Adam Sansier wrote:
On Wednesday, 13 July 2016 at 16:28:23 UTC, Lodovico Giaretta
wrote:
It's actually quite easy. Here's the code (untested):
On Wednesday, 13 July 2016 at 20:44:52 UTC, Adam Sansier wrote:
On Wednesday, 13 July 2016 at 16:28:23 UTC, Lodovico Giaretta
wrote:
It's actually quite easy. Here's the code (untested):
import
On Wednesday, 13 July 2016 at 16:28:23 UTC, Lodovico Giaretta
wrote:
On Wednesday, 13 July 2016 at 16:13:21 UTC, Adam Sansier wrote:
On Wednesday, 13 July 2016 at 11:39:11 UTC, Lodovico Giaretta
wrote:
On Wednesday, 13 July 2016 at 00:57:38 UTC, Adam Sansier
wrote:
[...]
You shall use a
On Wednesday, 13 July 2016 at 16:13:21 UTC, Adam Sansier wrote:
On Wednesday, 13 July 2016 at 11:39:11 UTC, Lodovico Giaretta
wrote:
On Wednesday, 13 July 2016 at 00:57:38 UTC, Adam Sansier wrote:
[...]
You shall use a static per-thread Region allocator[1] backed
by Mallocator[2].
Then you
I'm writing currently a library, that is 100% @nogc but not
nothrow, and I slowly begin to believe that I should publish it
already, though it isn't ready yet. At least as example.
std.experimental.allocator doesn't work nicely with @nogc. for
example dispose calls destroy, that isn't @nogc.
I
On Wednesday, 13 July 2016 at 11:39:11 UTC, Lodovico Giaretta
wrote:
On Wednesday, 13 July 2016 at 00:57:38 UTC, Adam Sansier wrote:
[...]
You shall use a static per-thread Region allocator[1] backed by
Mallocator[2].
Then you just make[3] exceptions inside it and throw them.
So you can
On Wednesday, 13 July 2016 at 00:57:38 UTC, Adam Sansier wrote:
How about simply setting aside a 100kb of memory as a pool for
exceptions. Seems like a lot but still under 640kb, hell, even
1MB would still be tiny.
After all, it's not like exceptions are common or happen in
complex ways.
On Friday, 13 February 2015 at 21:08:58 UTC, Marc Schütz wrote:
On Friday, 13 February 2015 at 19:09:43 UTC, Tobias Pankrath
wrote:
1. Throw preallocated exceptions is the way to go
... and because noone has yet shown an explicit example:
void myThrowingNogcFunc() @nogc {
static
On Friday, 13 February 2015 at 19:03:10 UTC, Jonathan Marler
wrote:
This question comes from wanting to be able to throw an
exception in code that is @nogc.
I don't know if it's possible but I'd like to be able to throw
an exception without allocating memory for the garbage
collector? You
On 2/13/15 2:03 PM, Jonathan Marler wrote:
This question comes from wanting to be able to throw an exception in
code that is @nogc.
I don't know if it's possible but I'd like to be able to throw an
exception without allocating memory for the garbage collector? You can
do it in C++ so I think
This question comes from wanting to be able to throw an exception
in code that is @nogc.
I don't know if it's possible but I'd like to be able to throw an
exception without allocating memory for the garbage collector?
You can do it in C++ so I think you should be able to in D. One
idea I
On Friday, 13 February 2015 at 19:13:02 UTC, Steven Schveighoffer
wrote:
You need to actually allocate the memory on the heap. Your data
lives on the stack frame of main, which goes away as soon as
main exits, and your exception is caught outside main.
-Steve
Yes I am aware of this. That
On Friday, 13 February 2015 at 19:03:10 UTC, Jonathan Marler
wrote:
T construct(T,A...)(void* buffer, A args)
{
return (cast(T)buffer).__ctor(args);
}
This is wrong, you need to initialize the memory first to the
proper values for the class, gotten via typeid(T).init.
std.conv.emplace does
On Friday, 13 February 2015 at 19:10:00 UTC, Adam D. Ruppe wrote:
On Friday, 13 February 2015 at 19:03:10 UTC, Jonathan Marler
wrote:
T construct(T,A...)(void* buffer, A args)
{
return (cast(T)buffer).__ctor(args);
}
This is wrong, you need to initialize the memory first to the
proper
On Friday, 13 February 2015 at 19:09:43 UTC, Tobias Pankrath
wrote:
1. Throw preallocated exceptions is the way to go
... and because noone has yet shown an explicit example:
void myThrowingNogcFunc() @nogc {
static const exc = new Exception(something went wrong);
throw
On 2/13/15 4:08 PM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net
wrote:
On Friday, 13 February 2015 at 19:09:43 UTC, Tobias Pankrath wrote:
1. Throw preallocated exceptions is the way to go
and because noone has yet shown an explicit example:
void myThrowingNogcFunc() @nogc {
20 matches
Mail list logo