Phobos 3 Discussion Notes - 02-01-2024

Jonathan M Davis newsgroup.d at jmdavisprog.com
Thu Feb 8 18:28:34 UTC 2024


On Wednesday, February 7, 2024 10:12:06 PM MST Paul Backus via Digitalmars-d 
wrote:
> On Wednesday, 7 February 2024 at 22:00:49 UTC, Jonathan M Davis
>
> wrote:
> > Allocators should be @safe where they can be, but I think that
> > a number of us came to the conclusion a while ago that they
> > couldn't be @safe in the general case. So, it'll be interesting
> > to see what you can come up with, but if @safe is a
> > requirement, I would expect that certain kinds of allocators
> > simply won't work. But that's no reason not to support @safe as
> > much as possible (particularly when code is templated).
>
> With -preview=dip1000 and -preview=systemVariables, it is
> possible to make pretty much any allocator @safe--although for
> some of them, the safety checking adds a little bit of runtime
> overhead.
>
> The main obstacle is that both of these -preview features are
> still very much unfinished, and will need a lot of work before
> they are ready to be used in real library code.
>
> By the way, one of the key techniques that makes this work is
> having the allocators wrap each void[] they return in a
> non-copyable struct, so that it can only be deallocated once. So
> you can probably understand why I'm so concerned about support
> for non-copyable types in Phobos v3. :)

Well, regardless of what we end up doing iwth non-copyable types in Phobos,
it's clear that the language needs improvements with regards to moving
objects, which we discussed in one of the recent DLF planning meetings. DIP
1048 (move constructors) was approved ages ago, but it still hasn't been
implemented yet, and to really make moving objects around even sort of
user-friendly, we need the compiler to start doing things like do a move
instead of a copy when it's the last use of a variable. And in particular,
if we decide that making basic input ranges non-copyable is the best
approach, then that's going to put pressure on getting that sorted out. The
range situation in Phobos v3 is still very much in the air though.

- Jonathan M Davis





More information about the Digitalmars-d mailing list