On Tuesday, 20 December 2016 at 20:08:32 UTC, Ali Çehreli wrote:
If the purpose is optimization, the good news are
Yes it is :)
* Classes are already reference types so there is no lvalue or
rvalue reference distinction there
Ok, this one is quite intuitive.
import std.stdio;
...
On Tuesday, 20 December 2016 at 19:24:32 UTC, Ali Çehreli wrote:
As a general rule, 'auto ref' should probably be const. If the
purpose of 'ref' is so that the argument would be mutated, then
allowing a copy of an rvalue to this function could very well
be a bug:
struct S {
int i;
}
On Sunday, 18 December 2016 at 14:32:08 UTC, kinke wrote:
TypeInfo_Struct apparently requires (or used to require) an
`int opCmp(ref const T rhs)` overload, i.e., a version taking
the rhs lvalue argument by reference (see
https://dlang.org/spec/operatoroverloading.html#compare). Note
that
On Sunday, 18 December 2016 at 14:25:04 UTC, Basile B. wrote:
...
As you can see, auto ref is more flexible with the parameter.
This make sense for templated functions.
Thank you for your detailed answer, things are perfectly clear
now. Also sorry for the doc linksI should have found it
Reading std/bigint.d code:
https://github.com/dlang/phobos/blob/00c1cc3b0d354363793c8b419ce84da722578138/std/bigint.d#L589
I have seen this:
bool opEquals()(auto ref const BigInt y) const pure @nogc
{
return sign == y.sign && y.data == data;
}
my problem is that I do not understand the
On Wednesday, 7 December 2016 at 16:15:32 UTC, Chris wrote:
I don't understand this discussion at all. Why not have both? I
don't need bare metal stuff at the moment but I might one day,
and I perfectly understand that people may need it. At the same
time, there are people who are happy
On Wednesday, 7 December 2016 at 11:48:32 UTC, bachmeier wrote:
I write D code all the time for my research. I want to write
correct code quickly. My time is too valuable to spend weeks
writing code to cut the running time by a few minutes. That
might be fun for some people, but it doesn't
On Tuesday, 6 December 2016 at 17:00:35 UTC, Jonathan M Davis
wrote:
So, while there are certainly folks who would prefer using D as
a better C without druntime or Phobos, I think that you're
seriously overestimating how many folks would be interested in
that. Certainly, all of the C++
On Thursday, 3 November 2016 at 05:16:11 UTC, Dlang User wrote:
I am running Debian Testing and I think I have run into the
recent fPIC issue. This is the source code for the test
project I am using:
import std.stdio;
void main()
{
writeln("Edit source/app.d to start your
Maybe interesting (hoping it is not too redundant with the links
here)
https://github.com/zhaopuming/awesome-d
Vincent
On Monday, 14 November 2016 at 17:15:43 UTC, Steven Schveighoffer
wrote:
What has happened is that the stack allocated for f() (and
since released) is still referenced by sb[]. In a weird way,
since you haven't called any other functions, that data is
still "valid"!
Thank you for the
On Monday, 14 November 2016 at 06:10:38 UTC, Jonathan M Davis
wrote:
I would have hoped that it would have complained about the
first one. I don't know why it isn't. It definitely results in
having a pointer to memory that should no longer be referenced.
Yes I would have hoped too, because
On Sunday, 13 November 2016 at 23:39:37 UTC, Steven Schveighoffer
wrote:
Note that he is declaring an int[10] inside the function and
then returning it. The compiler must see that the int[10] will
be returned, and so it reuses the pre-allocated buffer for
returning as the same address to
On Saturday, 12 November 2016 at 11:03:31 UTC, Mike Parker wrote:
Thank you very much for your clarifications & explanations, I am
reassured to see that things work like in C.
I will also look the links you provided, thank you again for your
time.
Vincent
Thank you for your answer cym13.
I reproduced your result for:
On Saturday, 12 November 2016 at 10:45:23 UTC, cym13 wrote:
void f_test() {
auto sb=f();
sb[2] = 100;
writeln(sb[2]); // prints 100
int test[100];
writeln(sb[2]); // prints 0
}
now I am convinced of the
Hi all,
Still learning... This time what surprised me is how static
arrays work.
I assume (is it true?) that for efficiency reason static size
arrays like int[10] are on the stack and do not involve dynamic
memory allocation:
First surprise: it is possible to share a static array:
void
On Thursday, 10 November 2016 at 20:12:10 UTC, Jonathan M Davis
wrote:
On Thursday, November 10, 2016 17:41:02 Picaud Vincent via
Digitalmars-d- learn wrote:
It is certainly a compiler problem: I used gdc -> compile
error, but with dmd it compiles and runs fine. Full details in
the git r
On Thursday, 10 November 2016 at 17:12:32 UTC, Jonathan M Davis
wrote:
On Thursday, November 10, 2016 15:46:11 Picaud Vincent via
Digitalmars-d- learn wrote:
[...]
Honestly, I'm surprised that the compiler let you alias
std.algorithm.comparison.min, because it's a templated
function
Hi All,
In my adventure to learn a little bit of D coming from C++ I am
now faced with the following problem:
I have read about "cross-module overloading", §5.5.2 page 146 of
Andrei Alexandrescu book.
That makes sense to me and this is interesting.
As a concrete example here the scenario:
Hi Basile,
Thank you for your code, it allowed me to grasp a little bit more
about how to do things in D.
Vincent
On Monday, 7 November 2016 at 23:07:27 UTC, Picaud Vincent wrote:
typo...
auto capacity = max(0,(size_-1)*stride_+1);
To be more correct I have something like:
alias IntergralConstant!(int,0) Zero_c;
alias IntergralConstant!(int,1) One_c;
auto capacity =
On Monday, 7 November 2016 at 22:18:56 UTC, Jerry wrote:
On Monday, 7 November 2016 at 21:37:50 UTC, Picaud Vincent
wrote:
static if ( isIntegralConstant!(typeof(required_capacity())
)
{
}
else
{
}
}
Premature post send by error sorry Well something like:
static if (
On Monday, 7 November 2016 at 21:23:37 UTC, Picaud Vincent wrote:
On Monday, 7 November 2016 at 18:59:24 UTC, Jerry wrote:
On Monday, 7 November 2016 at 18:42:37 UTC, Picaud Vincent
wrote:
template isIntegralConstant(ANY)
{
enum bool
On Monday, 7 November 2016 at 18:59:24 UTC, Jerry wrote:
On Monday, 7 November 2016 at 18:42:37 UTC, Picaud Vincent
wrote:
template isIntegralConstant(ANY)
{
enum bool
isIntegralConstant=__traits(identifier,ANY)=="IntegralConstant";
}
A bit more elegant way of doing that would be:
enum
Hi all,
I have ~15y of C++ and now I want to test D, because it seems
really intersting and "cleaner" than C++.
As an exercice I m trying to implement something equivalent to
the C++ std::integral_constant in D.
In D:
struct IntegralConstant(T, T VALUE) {
...
}
But I do not
25 matches
Mail list logo