On Tuesday, 28 August 2018 at 20:37:05 UTC, Everlast wrote:
Also, the biggest complaint is that when we use [] attached to
a type it has a specific meaning as "an array of". e.g., int[]
means an array of int's.
But int[] a... then changes as we don't have an array of int's
any more but
On Tuesday, 28 August 2018 at 20:39:16 UTC, aliak wrote:
Hi,
I'm trying to do something similar to what Kotlin allows with
assigning to member variables from a map. The syntax is very
readable and looks like:
class User(val map: Map) {
val name: String by map
val age: Int by map
On Tuesday, 28 August 2018 at 19:40:36 UTC, Paul Backus wrote:
On Tuesday, 28 August 2018 at 19:09:38 UTC, Everlast wrote:
Yeah, I see the link paul posted. The actual syntax seems a
bit strange to me...
We don't do
A[] a
So it is not "logical".
foo(A...)(A a)
but if A is a specific
Hi,
I'm trying to do something similar to what Kotlin allows with
assigning to member variables from a map. The syntax is very
readable and looks like:
class User(val map: Map) {
val name: String by map
val age: Int by map
}
So I'm trying to do something similar in D:
mixin
On Tuesday, 28 August 2018 at 19:09:38 UTC, Everlast wrote:
Yeah, I see the link paul posted. The actual syntax seems a bit
strange to me...
We don't do
A[] a
So it is not "logical".
foo(A...)(A a)
but if A is a specific type we must do
foo(int[] a ...)
The actual syntax then looks
On Tuesday, 28 August 2018 at 19:09:38 UTC, Everlast wrote:
On Tuesday, 28 August 2018 at 12:00:50 UTC, bauss wrote:
On Sunday, 26 August 2018 at 02:26:58 UTC, Everlast wrote:
in fact, I'd rather see
void print(T)(T t, int... a)
You were actually close.
void print(T)(T t, int[] a ...);
On Tuesday, 28 August 2018 at 12:00:50 UTC, bauss wrote:
On Sunday, 26 August 2018 at 02:26:58 UTC, Everlast wrote:
in fact, I'd rather see
void print(T)(T t, int... a)
You were actually close.
void print(T)(T t, int[] a ...);
Yeah, I see the link paul posted. The actual syntax seems a
On Tuesday, 28 August 2018 at 13:27:28 UTC, Simen Kjærås wrote:
Now, as has been pointed out, that only work for
null-coalescing, not null-propagation. It seems writers of
Optional, Variant, SumType, and so on, have decided not to
support this out of the box, but rather wrap it separately,
Hi all,
I have noticed that "protected static" doesn't work currently with
classes. In my case, I wanted to use "static immutable", but I have
tried regular static members and methods, and the same issue happens.
However, the puzzling part is that protected enums (which are a valid
On Tuesday, 28 August 2018 at 13:05:15 UTC, bauss wrote:
I'm not sure if there is a better way, but isInstanceOf
(std.traits) seems to work with a static foreach and a static
if.
template Qwerty(Values...)
{
static foreach (value; Values)
{
static if (!isInstanceOf!(Qaz,
On Monday, 27 August 2018 at 14:59:20 UTC, SG wrote:
On Monday, 27 August 2018 at 07:59:17 UTC, Simen Kjærås wrote:
That's the null propagation operator (?.). What SG asked for
is the null-coalescing operator (??). Of course, this can also
be implemented in D (albeit with a slight more
On Tuesday, 28 August 2018 at 12:28:19 UTC, Andrey wrote:
Hello,
Let we have two variadic templates:
template Qwerty(Values...) {}
template Qaz(alias type, Data...) {}
Now I want to add a constraint to "Qwerty" so that each type in
"Values" pack must be a "Qaz" template. I don't care about
On Tuesday, 28 August 2018 at 13:05:15 UTC, bauss wrote:
On Tuesday, 28 August 2018 at 12:28:19 UTC, Andrey wrote:
Hello,
Let we have two variadic templates:
template Qwerty(Values...) {}
template Qaz(alias type, Data...) {}
Now I want to add a constraint to "Qwerty" so that each type
in
On Tuesday, 28 August 2018 at 12:28:19 UTC, Andrey wrote:
Hello,
Let we have two variadic templates:
template Qwerty(Values...) {}
template Qaz(alias type, Data...) {}
Now I want to add a constraint to "Qwerty" so that each type in
"Values" pack must be a "Qaz" template. I don't care about
On Tuesday, 28 August 2018 at 12:28:19 UTC, Andrey wrote:
Hello,
Let we have two variadic templates:
template Qwerty(Values...) {}
template Qaz(alias type, Data...) {}
Now I want to add a constraint to "Qwerty" so that each type in
"Values" pack must be a "Qaz" template. I don't care about
Thanks for all your answers.
I'll have a look at the design and use casting if necessary.
Hello,
Let we have two variadic templates:
template Qwerty(Values...) {}
template Qaz(alias type, Data...) {}
Now I want to add a constraint to "Qwerty" so that each type in
"Values" pack must be a "Qaz" template. I don't care about values
of "type" or "Data" in "Qaz".
How to do it in D?
On Sunday, 26 August 2018 at 02:26:58 UTC, Everlast wrote:
in fact, I'd rather see
void print(T)(T t, int... a)
You were actually close.
void print(T)(T t, int[] a ...);
On Tuesday, 28 August 2018 at 10:48:20 UTC, Ivo wrote:
I'm writing a basic server program and I want to handle each
connection received in a new thread.
So here is the code I'm trying to produce:
while(true) {
auto client = socket.accept();
spawn( , client);
}
void
while(true) {
auto client = socket.accept();
spawn(, cast(shared)client);
}
void handleConnection(shared Socket sclient) {
Socket client=cast()sclient;
//do stuff like receive and send
}
Maybe http://libpipeline.nongnu.org/ can be an inspiration.
I'm writing a basic server program and I want to handle each
connection received in a new thread.
So here is the code I'm trying to produce:
while(true) {
auto client = socket.accept();
spawn( , client);
}
void handleConnection(Socket client) {
//do stuff like receive and send
}
On Saturday, 25 August 2018 at 13:33:58 UTC, SG wrote:
1) I program in C# and I'm wondering if there is something like
?? (Null-Coalescing Operator) in D? (I remember some proposals
in the past).
Another example:
https://github.com/aliak00/optional/blob/master/source/optional/optional.d#L340
On Tuesday, 28 August 2018 at 06:20:37 UTC, Sebastiaan Koppe
wrote:
On Tuesday, 28 August 2018 at 06:11:35 UTC, Jon Degenhardt
wrote:
The goal is to write the argument list once and use it to
create both the function and the Tuple alias. That way I could
create a large number of these function
On Tuesday, 28 August 2018 at 06:20:37 UTC, Sebastiaan Koppe
wrote:
On Tuesday, 28 August 2018 at 06:11:35 UTC, Jon Degenhardt
wrote:
The goal is to write the argument list once and use it to
create both the function and the Tuple alias. That way I could
create a large number of these function
On Monday, 27 August 2018 at 21:48:04 UTC, Alex wrote:
On Monday, 27 August 2018 at 19:36:29 UTC, aliak wrote:
Then Nullable!(int*) would be the same as int*. Or even better
maybe is to give a compiler error when you try and stuff a
nullable type inside a Nullable. Because ... why?
Isn't
On Tuesday, 28 August 2018 at 06:11:35 UTC, Jon Degenhardt wrote:
The goal is to write the argument list once and use it to
create both the function and the Tuple alias. That way I could
create a large number of these function / arglist tuple pairs
with less brittleness.
--Jon
I would
On Tuesday, 28 August 2018 at 06:11:35 UTC, Jon Degenhardt wrote:
I'd like to create a Tuple alias representing a function's
parameter list. Is there a way to do this?
[...]
Are you aware of
https://dlang.org/phobos/std_traits.html#Parameters
I'd like to create a Tuple alias representing a function's
parameter list. Is there a way to do this?
Here's an example creating a Tuple alias for a function's
parameters by hand:
import std.typecons: Tuple;
bool fn(string op, int v1, int v2)
{
switch (op)
{
29 matches
Mail list logo