D is our last hope

H. S. Teoh hsteoh at qfbox.info
Wed Dec 6 02:32:20 UTC 2023


On Wed, Dec 06, 2023 at 01:42:02AM +0000, monkyyy via Digitalmars-d wrote:
> On Tuesday, 5 December 2023 at 21:26:05 UTC, GrimMaple wrote:
> > worseD
> > half the std
> 
> I feel like the big thing is that slices depend on gc, and if you dont
> have slices how exactly can you use all the algorithms which, oh yeah,
> like to try to make ranges of dchar if you use any char then which
> wont be fitting in whatever you allocated
[...]

This is wrong, slices do not depend on gc.  *Appending* to slices does
(because you have to allocate memory to store the result), but you can
pass slices around @nogc code no problem. Taking slices of an existing
array (which need not be GC-allocated) is also @nogc. In fact, most of
std.algorithm, std.range, can be used with @nogc, the primary blocker
there is Exceptions which are GC-allocated.

(Incidentally this is why there was talk about @nogc Exceptions a while
back, the idea being that once we get rid of GC dependency for
Exception, then basically all of std.algorithm and std.range would be
usable in @nogc.)


T

-- 
Let X be the set not defined by this sentence...


More information about the Digitalmars-d mailing list