On Sunday, 31 December 2017 at 07:32:50 UTC, Ali Çehreli wrote:
On 12/30/2017 11:16 PM, Tim Hsu wrote:
> Struct version of Vector3f can't derive toString
> method. writeln() prints unformated struct members. I know I
can use
> helper function here. But is there any other way?
The normal way
On Sunday, 31 December 2017 at 07:16:46 UTC, Tim Hsu wrote:
I came from C++ looking forward to D. Some languages require
programmers to use GC all the time. However, A lot of time we
don't really need GC especially when the time of destruction is
deterministic in compile time.
[...]
You
On 12/30/17 8:57 PM, Tony wrote:
For me, it is confusing to use "slice" and "dynamic array" as synonyms.
My initial impression was that they must have different code underlying
them, and different behavior.
As stated in the slices article, I think of them as separate -- the
slice is the
On 12/30/17 10:08 PM, Ivan Trombley wrote:
double[] D = [3.14159];
Can you guess what D is? :D
An approximation of a slice of pi.
-Steve
On 12/31/17 6:16 AM, Tim Hsu wrote:
On Sunday, 31 December 2017 at 07:32:50 UTC, Ali Çehreli wrote:
On 12/30/2017 11:16 PM, Tim Hsu wrote:
> Struct version of Vector3f can't derive toString
> method. writeln() prints unformated struct members. I know I
can use
> helper function here. But is
On 12/31/17 7:50 AM, Steven Schveighoffer wrote:
Note, you can use a "sink" version of toString as well, and avoid the gc:
void toString(void delegate(const(char)[]) sink) @nogc
{
// use formatValue to push into the sink
}
I guess I'm missing some parameters here, go with what Seb
On Sunday, 31 December 2017 at 01:03:17 UTC, Tony wrote:
For me, front() should throw a pre-defined exception when
called on an empty range in order to eliminate undefined
behavior. It does take some time to make a check, but D does
array bounds checking by default. Ideally the front() check
On 12/31/2017 02:14 PM, aliak wrote:
Also, is going out of array bounds well defined behavior in D even with
boundscheck off?
No. Without the checks you get undefined behavior. I.e.,
`-boundscheck=off` defeats the `@safe` attribute. For that reason, I'd
advise against ever using it.
In Windows, exists, rename, copy will report file not exists when
you input non-English filename, such as Chinese 中文.txt
On Saturday, 30 December 2017 at 23:30:02 UTC, rjframe wrote:
On Sat, 30 Dec 2017 13:07:49 +, Marc wrote:
how do I take a symbol as parameter?
for example:
template nameof(alias S) {
import std.array : split;
enum nameof = S.stringof.split(".")[$-1];
}
Works fine for
On Sunday, 31 December 2017 at 22:50:12 UTC, Marc wrote:
On Saturday, 30 December 2017 at 23:30:02 UTC, rjframe wrote:
On Sat, 30 Dec 2017 13:07:49 +, Marc wrote:
how do I take a symbol as parameter?
for example:
[...]
Works fine for say a enum member such nameof!(myEnum.X) but
Alo! I'm making a recursive concat function that is similar to
chain. The following code works:
import std.range: isInputRange;
auto concat(R, V...)(R range, V values) if (isInputRange!R) {
import std.range: chain, ElementType;
static if (V.length) {
static if
On Sunday, 31 December 2017 at 13:32:03 UTC, aliak wrote:
Alo! I'm making a recursive concat function that is similar to
chain. The following code works:
[...]
I suspect it's because you've no 'else static if'.
Hello everyone,
I started to learn D a few weeks ago and have been stuck trying
to solve the following problem :
- determine at compile time whether an alias is defined or not in
a struct/class.
You'll find my attempt thereafter, something similar to how it's
done in C++ (using the type
On Sunday, 31 December 2017 at 13:14:10 UTC, aliak wrote:
On Sunday, 31 December 2017 at 01:03:17 UTC, Tony wrote:
For me, front() should throw a pre-defined exception when
called on an empty range in order to eliminate undefined
behavior. It does take some time to make a check, but D does
On Sunday, 31 December 2017 at 13:32:03 UTC, aliak wrote:
So it seems it tries to compile the statements below the check
on V.length even though it's guaranteed to be true and there's
a return statement inside the if.
Yeah, static if includes or excludes code independently at
compile time.
On Sunday, December 31, 2017 04:42:01 Tony via Digitalmars-d-learn wrote:
> On Sunday, 31 December 2017 at 04:20:28 UTC, codephantom wrote:
> > On Sunday, 31 December 2017 at 03:57:17 UTC, Tony wrote:
> >> On Sunday, 31 December 2017 at 03:08:05 UTC, Ivan Trombley
> >>
> >> wrote:
> >>> double[] D
On Sunday, 31 December 2017 at 14:24:40 UTC, Jonathan M Davis
wrote:
The D Slices article does an excellent job of explaining all of
this. It's just that it calls the GC-allocated memory buffer
the dynamic array instead of calling T[] the dynamic array like
the language and spec do.
On Sunday, December 31, 2017 01:57:58 Tony via Digitalmars-d-learn wrote:
> On Friday, 29 December 2017 at 23:13:20 UTC, Jonathan M Davis
>
> wrote:
> > The term "slice" is a bit overused in D, meaning a variety of
> > things. It doesn't help that some folks dislike the official
> > terminology.
On 12/31/17 10:01 AM, ktoast wrote:
Hello everyone,
I started to learn D a few weeks ago and have been stuck trying to solve
the following problem :
- determine at compile time whether an alias is defined or not in a
struct/class.
You'll find my attempt thereafter, something similar to
On Saturday, 30 December 2017 at 23:30:02 UTC, rjframe wrote:
On Sat, 30 Dec 2017 13:07:49 +, Marc wrote:
how do I take a symbol as parameter?
for example:
template nameof(alias S) {
import std.array : split;
enum nameof = S.stringof.split(".")[$-1];
}
Works fine for
On Sunday, December 31, 2017 14:49:40 Tony via Digitalmars-d-learn wrote:
> On Sunday, 31 December 2017 at 14:24:40 UTC, Jonathan M Davis
>
> wrote:
> > The D Slices article does an excellent job of explaining all of
> > this. It's just that it calls the GC-allocated memory buffer
> > the dynamic
On Sunday, December 31, 2017 01:03:17 Tony via Digitalmars-d-learn wrote:
> For me, front() should throw a pre-defined exception when called
> on an empty range in order to eliminate undefined behavior. It
> does take some time to make a check, but D does array bounds
> checking by default.
On 12/30/2017 11:00 AM, aliak wrote:
Instead of this:
auto result = range.op!f;
if (!result.empty) {
result.front.method();
}
This:
range.op!f.ifFront.method();
In the above scenario I only want method to be called if the pipeline
resulted in any element left in the range.
On Monday, 1 January 2018 at 02:10:14 UTC, Jonathan M Davis wrote:
The DLang Tour should probably be fixed to use the term dynamic
array though.
Or embrace both terms but take care that it is clear that they
are synonyms and one may be preferred depending on context. As a
beginner, I had
On Monday, January 01, 2018 05:06:46 Tony via Digitalmars-d-learn wrote:
> On Monday, 1 January 2018 at 02:10:14 UTC, Jonathan M Davis wrote:
> > The DLang Tour should probably be fixed to use the term dynamic
> > array though.
>
> Or embrace both terms but take care that it is clear that they
>
26 matches
Mail list logo