On 07/26/2016 10:11 AM, Bahman Movaqar wrote:
> Alright...further experiments. The following works:
>
> sort!((pp1, pp2) => cmp(pp1.price, pp2.price) > 0)(theRange)
>
> So it may be something about what kind of range I'm passing to `sort`.
> Am I right?
>
I meant
sort!((pp1, pp2) =>
On 07/26/2016 09:35 AM, Bahman Movaqar wrote:
> I have a range which is the result of a couple of chained range
> operations, and each element is:
>
> Tuple!(string, "product", double, "price")
>
> Now I'd like to sort the range by "price" using:
>
> sort!((pp1, pp2) => cmp(pp1.price,
I have a range which is the result of a couple of chained range
operations, and each element is:
Tuple!(string, "product", double, "price")
Now I'd like to sort the range by "price" using:
sort!((pp1, pp2) => cmp(pp1.price, pp2.price) > 0)(theRange)
But I get a compile time error:
On Tuesday, 26 July 2016 at 04:05:22 UTC, Charles Hixson wrote:
Yes, but I really despise the syntax they came up with. It's
probably good if most of your I/O is ranges, but mine hasn't
yet ever been. (Combining ranges with random I/O?)
that's why i wrote iv.stream, and then iv.vfs, with
Ahh I see, thanks guys.
On 07/25/2016 07:11 PM, ketmar via Digitalmars-d-learn wrote:
On Tuesday, 26 July 2016 at 01:19:49 UTC, Charles Hixson wrote:
then I will prefer the core.stdc.stdio approach. I find it's
appearance extremely much cleaner...
only if you are really used to write C code. when you see pointer,
On 07/25/2016 05:47 PM, Adam D. Ruppe wrote:
> On Monday, 25 July 2016 at 13:09:22 UTC, Bahman Movaqar wrote:
>> From what I could gather, it's not possible to check for `null` at
>> runtime for reference based types. Am I right?
>
> No, it is only possible to check for null for reference based
On Tuesday, 26 July 2016 at 01:19:49 UTC, Charles Hixson wrote:
then I will prefer the core.stdc.stdio approach. I find it's
appearance extremely much cleaner...
only if you are really used to write C code. when you see
pointer, or explicit type size argument in D, it is a sign of C
On 07/25/2016 05:18 PM, ketmar via Digitalmars-d-learn wrote:
On Monday, 25 July 2016 at 18:54:27 UTC, Charles Hixson wrote:
Are there reasons why one would use rawRead and rawWrite rather than
fread and fwrite when doiing binary random io? What are the advantages?
In particular, if one is
On Monday, 25 July 2016 at 22:57:05 UTC, Gorge Jingale wrote:
On Monday, 25 July 2016 at 22:27:11 UTC, Cauterite wrote:
On Monday, 25 July 2016 at 02:15:12 UTC, Gorge Jingale wrote:
Is there a static ternary if?
(A == B) ? C : D;
for compile type that works like static if.
You can pretty
On Monday, 25 July 2016 at 18:54:27 UTC, Charles Hixson wrote:
Are there reasons why one would use rawRead and rawWrite rather
than fread and fwrite when doiing binary random io? What are
the advantages?
In particular, if one is reading and writing structs rather
than arrays or ranges, are
On Monday, 25 July 2016 at 22:27:11 UTC, Cauterite wrote:
On Monday, 25 July 2016 at 02:15:12 UTC, Gorge Jingale wrote:
Is there a static ternary if?
(A == B) ? C : D;
for compile type that works like static if.
You can pretty easily make your own;
template staticIf(bool cond, alias a,
On Monday, 25 July 2016 at 02:15:12 UTC, Gorge Jingale wrote:
Is there a static ternary if?
(A == B) ? C : D;
for compile type that works like static if.
You can pretty easily make your own;
template staticIf(bool cond, alias a, alias b) {
static if (cond) {
alias staticIf = a;
Are there reasons why one would use rawRead and rawWrite rather than
fread and fwrite when doiing binary random io? What are the advantages?
In particular, if one is reading and writing structs rather than arrays
or ranges, are there any advantages?
On Sunday, 24 July 2016 at 07:54:11 UTC, Jonathan Marler wrote:
On Thursday, 21 July 2016 at 13:37:30 UTC, Saurabh Das wrote:
On Thursday, 21 July 2016 at 12:42:14 UTC, Adam D. Ruppe wrote:
On Thursday, 21 July 2016 at 09:41:27 UTC, Saurabh Das wrote:
Java 8 has a 'default' keyword that allows
On Monday, 25 July 2016 at 13:09:22 UTC, Bahman Movaqar wrote:
From what I could gather, it's not possible to check for `null`
at
runtime for reference based types. Am I right?
No, it is only possible to check for null for reference based
types. But map's result is not a reference based
On 07/25/2016 05:07 PM, Bahman Movaqar wrote:
> Suppose I have the following function:
>
> public auto max(alias comp, Range)(Range r)
> in {
> assert(r !is null && !r.empty);
> }
> body {
> // ...
> }
>
> When the function after a series of chained `map`
On Monday, 25 July 2016 at 05:00:23 UTC, Ali Çehreli wrote:
On 07/24/2016 07:15 PM, Gorge Jingale wrote:
Is there a static ternary if?
(A == B) ? C : D;
for compile type that works like static if.
The way to force an expression at compile time is to use it for
something that's needed at
On Monday, 25 July 2016 at 12:37:18 UTC, Bahman Movaqar wrote:
Suppose I have the following function:
public auto max(alias comp, Range)(Range r)
in {
assert(r !is null && !r.empty);
}
body {
// ...
}
When the function after a series of chained `map` operations,
On Monday, 25 July 2016 at 12:47:25 UTC, Cauterite wrote:
(!__traits(compiles, r is null) || r !is null) && !r.empty
Ah, whoops that's wrong, looks like ketmar had the right idea.
On Monday, 25 July 2016 at 12:37:18 UTC, Bahman Movaqar wrote:
But I'm curious; how can I check for a
`null` in this case?
Well, if you're happy with assertion failure by access violation,
you may not even need to check for null, because generally if you
try to call .empty on a null pointer
On Monday, 25 July 2016 at 12:37:18 UTC, Bahman Movaqar wrote:
Error: incompatible types for ((r) !is (null)):
'MapResult!(__lambda2, SInvoiceLine[])' and 'typeof(null)'
Of course if I remove `r !is null` from the `in` block,
everything will work. But I'm curious; how can I check for a
static if (is(typeof(r is null))) { ...you can do your assert
here... }
Suppose I have the following function:
public auto max(alias comp, Range)(Range r)
in {
assert(r !is null && !r.empty);
}
body {
// ...
}
When the function after a series of chained `map` operations, I get the
following error:
Error: incompatible types for
On 7/25/16 5:54 AM, Kagamin wrote:
Cast it to Object:
FooInterface a = new BarImplementsInterface();
FooBaseClass b = new BarDerivedClass();
Object o = cast(Object)a;
writefln("a class: %s", a.classinfo.name);
writefln("b class: %s", b.classinfo.name);
writefln("o class:
dub build has the --compiler= option.
Is there any way to set it to default a custom version (own
branch, resides in ../../ldcbuild/bin/ldc2 ) of ldc2 in the
dub.json (or .sdl)?
The project will only compile with that compiler.
On 7/23/16 5:44 PM, Rufus Smith wrote:
On Saturday, 23 July 2016 at 17:27:24 UTC, Lodovico Giaretta wrote:
On Saturday, 23 July 2016 at 17:04:42 UTC, Jonathan Marler wrote:
On Saturday, 23 July 2016 at 16:46:20 UTC, Jonathan Marler wrote:
[...]
Actually Im going to disagree with myself.
On Sunday, 24 July 2016 at 00:54:21 UTC, Zekereth wrote:
On Saturday, 23 July 2016 at 19:08:00 UTC, WhatMeWorry wrote:
What I thought would be trivial is becoming a nightmare. Can
anybody set me straight. Thanks in advance.
[...]
Use the getchar() function.
void pause(const string msg =
On Sunday, 24 July 2016 at 15:38:13 UTC, lqjglkqjsg wrote:
On Sunday, 24 July 2016 at 15:07:20 UTC, Jack wrote:
[...]
- You can use a 3rd module that imports the two that "cycle".
- You can use another singleton implementation that doesn't
rely on a static this. e.g a kind of "lazy factory"
yep, cast it. without the cast, compiler assuming that it knows
the type in runtime, and is using well-known classinfo address
instead of really looking into instance for that.
Cast it to Object:
FooInterface a = new BarImplementsInterface();
FooBaseClass b = new BarDerivedClass();
Object o = cast(Object)a;
writefln("a class: %s", a.classinfo.name);
writefln("b class: %s", b.classinfo.name);
writefln("o class: %s",
On Monday, July 25, 2016 04:58:55 Gorge Jingale via Digitalmars-d-learn wrote:
> debug mixin("public"); else mixin("private");
>
> Doesn't work.
>
> It's nice to have public members when debugging because they show
> up in the debugger and one can access internals for checking. One
> can enable
I'm having trouble getting the full name of an object of a class
that implements an interface, using typeid() or .classinfo, the
behavior seems to be different from that of a class that simply
derives other classes.
interface FooInterface {}
class BarImplementsInterface : FooInterface {}
On Saturday, 23 July 2016 at 21:30:52 UTC, yawniek wrote:
On Friday, 22 July 2016 at 12:36:31 UTC, Alexander Milushev
wrote:
I there any json serialization library which allow to make
decision about ignoring fields in runtime? I trying to write
rest client but server accept either 'cmd' or
On Saturday, 23 July 2016 at 12:27:24 UTC, ParticlePeter wrote:
Is there any kind of project or workflow that converts D
(subset) to C/CPP ?
The short answer is no, not for any recent version of D.
35 matches
Mail list logo