On Tuesday, 30 June 2020 at 16:22:57 UTC, JN wrote:
Why does such code compile? I don't think this should be
permitted, because it's easy to make a mistake (when you wanted
foo[index] but forgot the []). If someone wants to assign a
value to every element they could do foo[] = 5; instead which
On Thursday, 9 July 2020 at 12:12:06 UTC, wjoe wrote:
Also GC but it's possible to make a dynamic array
implementation which avoids the GC.
It's easy to make a dynamic array without using the GC. Did you
mean "implementation which avoids memory management"?
I'm not considering supposed perform
I was learning copy constructors and got a really weird result.
It looks like a copy constructor and a destuctor of two unknown
objects are called. Could somebody please explain it to me?
import std.stdio;
struct Foo {
int value;
this(int n)
{
value =
I just didn't expect that the address of a "this" reference may
change.
On Thursday, 9 July 2020 at 22:18:59 UTC, Steven Schveighoffer
wrote:
Looking at the generated AST, it's because the compiler is
adding an auto-generated opAssign, which accepts a Foo by
value. It is that object that is being created and destroyed.
Is there a reason the autogenerated opAssign
On Friday, 10 July 2020 at 10:13:23 UTC, wjoe wrote:
However stack memory needs to be allocated at program start. I
don't see a huge benefit in allocation speed vs. heap
pre-allocation, or is there?
I mean 1 allocation vs 2 isn't going to noticeably improve
overall performance.
Allocation on
Is it possible to make a comparison predicate with different
argument types? For instance, suppose I have a struct like this:
struct Attribute {
string name;
variant value;
}
Also, suppose I have a sorted vector of such values. So I can
quickly find one by its name field and I have ind
auto sorted = object_.assumeSorted!((a, b) => a.name < b.name);
Sorry for the copy-paste. It should be "attributes" in place of
"object_" here, of course:
auto sorted = attributes.assumeSorted!((a, b) => a.name < b.name);
On Wednesday, 13 February 2019 at 11:32:46 UTC, envoid wrote:
Is there an article that explains best practices of using const
in D?
You can find some information here:
https://dlang.org/articles/const-faq.html