On Tuesday, 21 April 2015 at 06:56:33 UTC, Per Nordlöw wrote:
On Monday, 20 April 2015 at 13:49:41 UTC, John Colvin wrote:
On Thursday, 16 April 2015 at 18:12:35 UTC, Nordlöw wrote:
Is there a way to CT-query the arity of all opIndex and
opSlice overloads?
Further, this is slightly related
On Monday, 20 April 2015 at 13:49:41 UTC, John Colvin wrote:
On Thursday, 16 April 2015 at 18:12:35 UTC, Nordlöw wrote:
Is there a way to CT-query the arity of all opIndex and
opSlice overloads?
Ideally you don't want to have to do that. You'd have to
consider alias this and inheritance.
On 2015-04-20 20:05, Steven Schveighoffer wrote:
enum LineStyle : string {
NONE = None,
SOLID = Solid,
... // etc
}
Used like this:
funcThatTakesString(LineStyle.NONE);
LineStyle ls = LineStyle.SOLID;
funcThatTakesLineStyle(ls);
I'm not a Java programmer, and my time with Java
On 2015-04-21 17:36, Jadbox wrote:
What's the best equivalent to Rust's structural enum/pattern (match)ing?
Is it also possible to enforce exhaustive matches? Basically, I'm
curious on what the best way to do ADTs in D.
There's something call castSwitch [1], perhaps not what you're looking
On Tuesday, 21 April 2015 at 07:46:03 UTC, Vlad Levenfeld wrote:
Then you throw in some more stuff to detect 1-dimensional cases.
Could you please elaborate a bit?
On Tuesday, 21 April 2015 at 19:17:56 UTC, kevin wrote:
On Tuesday, 21 April 2015 at 19:13:34 UTC, Meta wrote:
On Tuesday, 21 April 2015 at 19:11:43 UTC, John Colvin wrote:
On Tuesday, 21 April 2015 at 19:06:39 UTC, kevin wrote:
enum bool isInputRange = is(typeof(
(inout int = 0)
{
R r
enum bool isInputRange = is(typeof(
(inout int = 0)
{
R r = R.init; // can define a range object
if (r.empty) {} // can test for empty
r.popFront(); // can invoke popFront()
auto h = r.front; // can get the front of the range
}));
... is the
On Tuesday, 21 April 2015 at 19:13:34 UTC, Meta wrote:
On Tuesday, 21 April 2015 at 19:11:43 UTC, John Colvin wrote:
On Tuesday, 21 April 2015 at 19:06:39 UTC, kevin wrote:
enum bool isInputRange = is(typeof(
(inout int = 0)
{
R r = R.init; // can define a range object
if
On Tuesday, 21 April 2015 at 19:06:39 UTC, kevin wrote:
enum bool isInputRange = is(typeof(
(inout int = 0)
{
R r = R.init; // can define a range object
if (r.empty) {} // can test for empty
r.popFront(); // can invoke popFront()
auto h =
On Tuesday, 21 April 2015 at 19:11:43 UTC, John Colvin wrote:
On Tuesday, 21 April 2015 at 19:06:39 UTC, kevin wrote:
enum bool isInputRange = is(typeof(
(inout int = 0)
{
R r = R.init; // can define a range object
if (r.empty) {} // can test for empty
On 4/21/15 3:11 PM, John Colvin wrote:
On Tuesday, 21 April 2015 at 19:06:39 UTC, kevin wrote:
enum bool isInputRange = is(typeof(
(inout int = 0)
{
R r = R.init; // can define a range object
if (r.empty) {} // can test for empty
r.popFront(); // can
On Tuesday, 21 April 2015 at 07:01:27 UTC, Per Nordlöw wrote:
On Tuesday, 21 April 2015 at 06:56:33 UTC, Per Nordlöw wrote:
On Monday, 20 April 2015 at 13:49:41 UTC, John Colvin wrote:
On Thursday, 16 April 2015 at 18:12:35 UTC, Nordlöw wrote:
Is there a way to CT-query the arity of all
test.d
---
void main()
{
import std.net.curl;
import std.stdio;
writeln(get(http://google.com;));
}
---
rdmd -g test.d
---
std.net.curl.CurlException@std\net\curl.d(3691): couldn't resolve
host name on handle 26B4878
0x0040572A in pure @safe void
Chris:
I'm happy with it, but maybe there is a more concise
implementation?
This is a bit shorter and a bit better (writefln is not yet able
to format tuples nicely):
void main() {
import std.stdio: writeln;
import std.algorithm.sorting: multiSort;
import std.array: array;
std.datetime contains parseRFC822DateTime to convert from an
RFC822/RFC5322 formatted string (ala Sat, 6 Jan 1990 12:14:19
-0800) to a SysTime.
Does it contain anything for the converse - converting from a
SysTime to Sat, 6 Jan 1990 12:14:19 -0800?
If not, should it?
As an aside, I've put a bit of work into the generic
multidimensional containers problem lately and have an interface
generating library as a result.
https://github.com/evenex/autodata
It's still in the nascent stages but contains a lot of tools for
working with multidimensional structures.
Maybe something like bearophile's example should go into the
documentation of std.algorithm.sorting.multiSort. It's a common
enough thing in programming.
On Tuesday, 21 April 2015 at 07:46:03 UTC, Vlad Levenfeld wrote:
template dimensionality (S) {
template count_dim (uint i = 0) {
static if (is (typeof(S.init.opSlice!i (0,0
enum count_dim = count_dim!(i+1);
else enum count_dim = i;
}
alias dimensionality = count_dim!();
On Tuesday, 21 April 2015 at 08:09:38 UTC, Per Nordlöw wrote:
On Tuesday, 21 April 2015 at 07:46:03 UTC, Vlad Levenfeld wrote:
template dimensionality (S) {
template count_dim (uint i = 0) {
static if (is (typeof(S.init.opSlice!i (0,0
enum count_dim = count_dim!(i+1);
else enum
On Monday, 20 April 2015 at 21:36:35 UTC, Ali Çehreli wrote:
final class Foo {
uint id;
@nogc
this(uint id) {
this.id = id;
}
}
C reuse(C, T...)(ref C old, T ctorParams)
{
import std.conv;
import std.typetuple;
enum objectSize = __traits(classInstanceSize,
On Monday, 20 April 2015 at 20:22:40 UTC, Jonathan M Davis wrote:
There may be languages out there which take the the return type
into account
when overloading, but I've never seen one.
Rust does, as far as I know.
I don't think that the ambiguities are an insurmountable
obstacle. It's
On Tuesday, 21 April 2015 at 13:27:48 UTC, Marc Schütz wrote:
On Monday, 20 April 2015 at 20:22:40 UTC, Jonathan M Davis
wrote:
There may be languages out there which take the the return
type into account
when overloading, but I've never seen one.
Rust does, as far as I know.
And this is
On Tuesday, April 21, 2015 08:14:10 Jakob Ovrum via Digitalmars-d-learn wrote:
std.datetime contains parseRFC822DateTime to convert from an
RFC822/RFC5322 formatted string (ala Sat, 6 Jan 1990 12:14:19
-0800) to a SysTime.
Does it contain anything for the converse - converting from a
SysTime
On Tuesday, 21 April 2015 at 10:28:32 UTC, Jonathan M Davis wrote:
On Tuesday, April 21, 2015 08:14:10 Jakob Ovrum via
Digitalmars-d-learn wrote:
std.datetime contains parseRFC822DateTime to convert from an
RFC822/RFC5322 formatted string (ala Sat, 6 Jan 1990 12:14:19
-0800) to a SysTime.
Does
On Tuesday, 21 April 2015 at 11:46:24 UTC, bearophile wrote:
Chris:
I'm happy with it, but maybe there is a more concise
implementation?
This is a bit shorter and a bit better (writefln is not yet
able to format tuples nicely):
void main() {
import std.stdio: writeln;
import
What's the best equivalent to Rust's structural enum/pattern
(match)ing? Is it also possible to enforce exhaustive matches?
Basically, I'm curious on what the best way to do ADTs in D.
Jadbox:
I'm curious on what the best way to do ADTs in D.
Sometimes there's no best way, there are several alternative ways
with different tradeoffs. D isn't a functional language and
there's no really good way to do ADTs in D. You can use plus a
final switch. Or you can use Algebraic from
On Tuesday, 21 April 2015 at 20:30:00 UTC, Vlad Levenfeld wrote:
Should work for any case I can think of (assuming integral
indices).
Thanks.
template dimensionality (S) {
template count_dim (uint i = 0) {
static if (is (typeof(S.init.opSlice!i (0,0
enum count_dim = count_dim!(i+1);
else static if (i == 0 (isInputRange!S || is
(typeof(S.init[0])))
enum count_dim = 1;
else enum count_dim = i;
}
On Tuesday, 21 April 2015 at 19:46:03 UTC, Nordlöw wrote:
On Tuesday, 21 April 2015 at 07:46:03 UTC, Vlad Levenfeld wrote:
Then you throw in some more stuff to detect 1-dimensional
cases.
Could you please elaborate a bit?
Well assuming the type is not multidimensional (does not define
On 04/21/2015 12:06 PM, kevin wrote:
enum bool isInputRange = is(typeof(
(inout int = 0)
{
R r = R.init; // can define a range object
if (r.empty) {} // can test for empty
r.popFront(); // can invoke popFront()
auto h = r.front; // can get
On Wed, 22 Apr 2015 01:02:15 +, Mark Isaacson wrote:
I'd like to be able to know if my destructor is being called because an
exception was thrown. Any way to do that?
sorry, you can't.
signature.asc
Description: PGP signature
Oh well :(.
Yeah, it's just for debugging. I want to publish a script that
automatically gathers relevant debug information so that my users
can just copy paste it all into one place, ready for me to take a
look even if I can't repro. One of the primitives in my script is
a wrapper around
On Wednesday, April 22, 2015 01:02:15 Mark Isaacson via Digitalmars-d-learn
wrote:
I'd like to be able to know if my destructor is being called
because an exception was thrown. Any way to do that?
I tried this: http://ideone.com/JbXH2w
(Pasted here for convenience):
import std.stdio,
On Tuesday, 21 April 2015 at 15:36:28 UTC, Jadbox wrote:
What's the best equivalent to Rust's structural enum/pattern
(match)ing? Is it also possible to enforce exhaustive matches?
Basically, I'm curious on what the best way to do ADTs in D.
If it needs to be really fast, use final switch on
Hello!
I am trying to interface to C++, and getting linker errors. Below are my 3
source files and 2 build scripts with their associated errors. Can anyone
see what I'm doing wrong?
/ test.cpp
#include stdio.h
class Test {
public:
virtual void Foo(){
I'd like to be able to know if my destructor is being called
because an exception was thrown. Any way to do that?
I tried this: http://ideone.com/JbXH2w
(Pasted here for convenience):
import std.stdio, std.exception;
struct Catcher {
~this() {
try {} catch (Exception
The following works great. It sorts an AA by value:
1. by frequency of word
2. by alphabetic order (if two or more words have the same value)
import std.stdio : writefln;
import std.algorithm.sorting : multiSort;
void main() {
size_t[string] wcount = [
hamster:5,
zorro:80,
This isn't about type system per se but about preferred style of
syntax. Original example that caused my hatred looked like this:
`let i : uint = from_str(42)`. Fortunately this has been
deprecated in favor of `parse` but same principle applies - Rust
authors encourage you to use declaration
On Tuesday, 21 April 2015 at 15:36:28 UTC, Jadbox wrote:
What's the best equivalent to Rust's structural enum/pattern
(match)ing? Is it also possible to enforce exhaustive matches?
Basically, I'm curious on what the best way to do ADTs in D.
D's ADTs are in std.variant, the equivalent of
On Tuesday, 21 April 2015 at 13:53:15 UTC, Dicebot wrote:
On Tuesday, 21 April 2015 at 13:27:48 UTC, Marc Schütz wrote:
On Monday, 20 April 2015 at 20:22:40 UTC, Jonathan M Davis
wrote:
There may be languages out there which take the the return
type into account
when overloading, but I've
On Tue, 21 Apr 2015 15:36:27 +, Jadbox wrote:
What's the best equivalent to Rust's structural enum/pattern (match)ing?
Is it also possible to enforce exhaustive matches?
Basically, I'm curious on what the best way to do ADTs in D.
std.variant.Algebraic implements ADTs:
import
42 matches
Mail list logo