Future of memory management in D

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Nov 18 17:37:51 UTC 2021


On Thu, Nov 18, 2021 at 03:19:39PM +0000, Rumbu via Digitalmars-d wrote:
> On Thursday, 18 November 2021 at 15:00:22 UTC, JN wrote:
> > On Thursday, 18 November 2021 at 14:56:40 UTC, rumbu wrote:
> > > > > * pattern matching on fields/properties
> > > > 
> > > > How would this work?
> > > 
> > > 
> > > ```d
> > > switch (JSONValue)
> > > {
> > >    case JSONNumber n: writeln ("I have a number %s", n);
> > >    case JSONString s when s.Length > 100 : writeln("long string");
> > >    case JSONString s: writeln("short string");
> > > }
> > > 
> > > ```
> > 
> > Isn't that just std.sumtype/tagged union?
> 
> Yes, it is, but the question was about oop evolution in D and keeping
> the pace with other languages, not about "here you have another lib
> for this".
[...]

IMO, this is actually a strength of D: it is powerful enough to express
these constructs as library code instead of being baked into the
language.

Of course, the library experience definitely can be improved -- I don't
argue with that.  Some language changes to make library solutions more
powerful would definitely be welcome.  Documentation needs improvement,
and ecosystem definitely needs work.  But I don't see library solutions
as a failure; I see it rather as a success that libraries are able to
express such things, whereas in languages like Java the language doesn't
let you express them, so you have no choice except to bake it into the
language.


T

-- 
Stop staring at me like that! It's offens... no, you'll hurt your eyes!


More information about the Digitalmars-d mailing list