Symbolic computations in D

evilrat evilrat666 at gmail.com
Sun Oct 29 10:08:42 UTC 2023


On Sunday, 29 October 2023 at 08:55:24 UTC, Dmitry Ponyatov wrote:
> Maybe someone played in this topic, and can give some advice:
> is D language with its OOP without multiple inheritance and 
> maybe other semantic limitations able and good enough to be 
> used with these books mechanics?

You can have multiple interfaces, and interfaces can have default 
implementation for its methods.
What really prohibited is to have multiple base classes as this 
will over complicate data layout and the compiler without much 
benefit (if any at all).

What are semantic limitations you talking about? D is much more 
expressive than C++, there is also CTFE and code generation with 
mixins.

Mixins can do pretty much anything preprocessor can, except they 
can't inject self-invocable code, you always need an explicit 
"mixin(foo)" statement, and that's the only limitation compared 
to preprocessor.
IIRC Vibe.d using them for template engine.

Also D has raw strings, just like this
https://github.com/buggins/dlangui/blob/master/examples/dmledit/src/dmledit.d#L73

Which again with mixins can be turned into DSL(domain specific 
language),
with this you can write your own template that parses that string 
and for example builds a widget tree out of it, like this
https://github.com/buggins/dlangui/blob/master/examples/helloworld/src/helloworld.d#L20


More information about the Digitalmars-d-learn mailing list