Thanks for the thorough explanation. Most of that is how I was
thinking it worked. However, that leaves me perplexed. If
templates just generate code then how come:
Wouldnt..
class SomeClass(T) : ISomeInterface!T
and..
class SomeOtherClass(T) : ISomeInterface!T
...generate two diffe
I come from both a C++ and C# background. Those have been the
primary languages I have used. In C# you can do something like
this:
public interface ISomeInterface
{
T Value { get; }
}
public class SomeClass : ISomeInterface
{
T Value { get; set; }
}
On Thursday, 10 October 2019 at 15:56:36 UTC, Just Dave wrote:
I'm trying to get my head around mixing templates. I'm using it
as kind of a replacement for class inheritance as it seems to
fit better composition over inheritance. So I do something like:
mixin template NumberTemplate()
On Thursday, 10 October 2019 at 15:53:20 UTC, Adam D. Ruppe wrote:
On Thursday, 10 October 2019 at 15:47:58 UTC, Just Dave wrote:
if (obj is Person person)
Looks the same as D's
if(auto person = cast(Person) obj) {
// use person in here
} else {
// it was some other type
}
Excellent
I'm trying to get my head around mixing templates. I'm using it
as kind of a replacement for class inheritance as it seems to fit
better composition over inheritance. So I do something like:
mixin template NumberTemplate()
{
private:
int number = 0;
public:
int g
Even though static solutions would be more performance minded,
I'd actually prefer to see the runtime equivalent so I don't have
to rethink how I think as performance isn't really my major
concern right now.
In C# you can do something like:
if (obj is Person)
{
var person = obj as Person;
// do stuff with person...
}
where you can check the type of an object prior to casting. Does
D have a similar mechanism? It's so widely useful in the C# realm
that they even added sy
Thanks for the advice. I used a quick and dirty range solution as
was suggested. It allowed me to move on as I really wasn't
looking to fully implement a queue or stack. Just get something
that semantically behaved as such. I'll return later and optimize
it with the later suggestions if it's a
On Monday, 7 October 2019 at 17:24:19 UTC, Ferhat Kurtulmuş wrote:
On Monday, 7 October 2019 at 17:11:08 UTC, Just Dave wrote:
I need a stack and a queue and I noticed that the standard
library doesn't appear to have one. Which is ok. I just need
something that can logically behave as a stack a
On Monday, 7 October 2019 at 17:18:03 UTC, bachmeier wrote:
On Monday, 7 October 2019 at 17:11:08 UTC, Just Dave wrote:
I need a stack and a queue and I noticed that the standard
library doesn't appear to have one. Which is ok. I just need
something that can logically behave as a stack and queu
I need a stack and a queue and I noticed that the standard
library doesn't appear to have one. Which is ok. I just need
something that can logically behave as a stack and queue, which I
think the dynamic array should be able to do (if I understand
correctly this is effectively the equivalent of
A machine reboot seems to have fixed the problem...
I downloaded it after experiencing debugging issues with
CodeBlocks (it wouldn't attach the provided debugger). I
downloaded Visual D and after some fiddling with Visual Studio
2019 not supporting third party templates in my version (had to
update it), I haven't been able to get Visual D to com
I was reading the C++ to D page, and came across this little bit
about when to call the base class constructor:
"It's superior to C++ in that the base constructor call can be
flexibly placed anywhere in the derived constructor."
Isn't there some inherent danger of not calling the base
constr
Greetings,
This might be totally obvious, but I can't seem to figure out how
to specify an executable's name&path to be different for each
build types in my DUB package. For example, if my project is
named "dlang_test", I might want something like so:
dub build --build=debug
yields either
15 matches
Mail list logo