On Thursday, 14 June 2018 at 19:15:38 UTC, uknys wrote:
Hello,
I wanted to know if such code was possible :
alias Operation = Algebraic!(/* All type that implements X UDA
*/)
struct X
{
int opcode;
Operation h;
}
@X(0x01, Hello(3))
@X(0x02, Hello(4))
struct Hello
{
int Hello;
}
On Tuesday, 12 June 2018 at 11:04:40 UTC, bauss wrote:
[snip]
void test(T)()
{
pragma(msg, (getBar!T).baz());
pragma(msg, (getBar!T).helloworld());
import std.stdio;
mixin((getBar!T).baz());
mixin((getBar!T).helloworld());
}
[snip]
Is there a way to avoid having to write
On Wednesday, 6 June 2018 at 06:25:49 UTC, DaggetJones wrote:
Hi, I'm wondering how I should approach supplying
functions/delegates around in D. I have option of using classes
where the function exists inside the class and to provide
different functionality different classes are created.
On Tuesday, 5 June 2018 at 09:36:22 UTC, Gopan wrote:
void main()
{
immutable n = __ctfe ? 1 : 2;
int[n] a;
assert(a.length == n); // fails, wat
}
That's gotta be a bug - that should give a 'variable n cannot be
read at compile time' error. The fact that n is immutable
shouldn't
On Sunday, 3 June 2018 at 14:57:37 UTC, DigitalDesigns wrote:
On Sunday, 3 June 2018 at 09:52:01 UTC, Malte wrote:
You might want to have a look at
https://wiki.dlang.org/Dynamic_typing
This sounds very similar to what you are doing. I never really
looked into it, because I prefer to know
On Saturday, 2 June 2018 at 22:09:49 UTC, Neia Neutuladh wrote:
On Saturday, 2 June 2018 at 21:44:39 UTC, greatsam4sure wrote:
Sorry for the typo
is it possible to define infix function in D
3.min(5)// 3: where min is a function, works in D
3 min 5 // does not work.
thanks in advance
This
On Monday, 28 May 2018 at 20:13:49 UTC, DigitalDesigns wrote:
I do not think this is a problem in D. Infinite recursion can
always be terminated with appropriate means.
1. Use attributes. methods in class A should be marked as being
for the interface. When added to the interface they will not
On Wednesday, 30 May 2018 at 09:58:16 UTC, biocyberman wrote:
How do I add logging for this struct?
https://run.dlang.io/is/9N6N4o
If not possible, what's the alternative?
This line:
writeln("got num: %s, of type: %s", num, typeof(num));
Gives this error message:
onlineapp.d(7):
On Tuesday, 29 May 2018 at 21:19:01 UTC, DigitalDesigns wrote:
https://dpaste.dzfl.pl/67691db19ce8
Simplified:
interface A
{
import std.meta : AliasSeq;
alias a = AliasSeq!(__traits(getMember, B, "foo"));
void foo();
}
class B : A
{
void foo() { }
}
It seems the compiler is
On Monday, 28 May 2018 at 09:59:50 UTC, DigitalDesigns wrote:
Implementing interfaces can be a pain but are necessary.
I like to use abstract classes and provide a base
implementation. It would be cool if I could use D's awesome
meta features to extract the interface from the abstract class
On Sunday, 27 May 2018 at 17:42:15 UTC, Sobaya wrote:
I'd like to get symbols that have an UDA.
But when the member is private, it is not obtained.
And I found a comment saying "Filtering inaccessible members"
in the source.
Why is it necessary to filter out private members?
Since the
On Thursday, 24 May 2018 at 07:47:54 UTC, Andrea Fontana wrote:
Is this a bug or am I missing something?
https://run.dlang.io/is/OGHJYX
Andrea
This line:
mixin("alias tmp = " ~ s ~ ";");
There's no mention of Symbol in there. If you change it to this:
mixin("alias tmp =
On Saturday, 19 May 2018 at 18:44:42 UTC, IntegratedDimensions
wrote:
On Saturday, 19 May 2018 at 18:19:35 UTC, IntegratedDimensions
wrote:
Is there any way to create an int24 type that behaves just
like any other built in type without having to reimplement
everything?
In fact, what I'd like
On Wednesday, 9 May 2018 at 10:16:22 UTC, Melvin wrote:
class SomeNode : GodotScript!Node
{
@Signal void testSignal(float a, long b);
// The declaration above would trigger the generation of
this line
void testSignal(float a, long b) {
owner.emitSignal("testSignal", a, b); }
On Friday, 4 May 2018 at 13:02:08 UTC, NewUser wrote:
How can I use the following c structure from d.
struct Item
{
int id;
};
struct Group
{
int i;
int item_count;
struct Item items[];
};
tried defining items[] as both "Item[] items" and "Item* items"
in d, it compiles okay but
On Friday, 27 April 2018 at 13:27:45 UTC, Timoses wrote:
Bumped across another problem : /
```
import std.stdio;
enum menum { A, B, C }
void main()
{
foo(menum.A);
}
void foo(menum e)
{
writeln(instantiateWith!Temp(e));
}
auto instantiateWith(alias Fn, T)(T x)
if (is(T == enum))
On Thursday, 26 April 2018 at 16:10:16 UTC, Timoses wrote:
Is it possible to use a template to place the "static foreach"
looping to find the correct enum value into? Like I am trying
in the initial "draft" GetMenum?
As the compiler says, the value of `e` is not known at
compile-time. In
On Wednesday, 25 April 2018 at 11:26:40 UTC, Vijay Nayar wrote:
On Wednesday, 25 April 2018 at 10:25:11 UTC, Simen Kjærås wrote:
In the general case, the issue is unsolvable, since the
relationship between template parameters and alias results may
be arbitrarily complex. A simple degenerate
On Wednesday, 25 April 2018 at 07:39:28 UTC, Vijay Nayar wrote:
I have encountered a problem where whenever I attempt to use a
templated function with alias that partially limits the type of
the arguments, the program fails to compile. But if I avoid
using an alias, the same function can
On Monday, 23 April 2018 at 15:00:38 UTC, Alex wrote:
Ok, thats exactly the point. If you have functions
void foo() {}
void foo(int n) {}
There is no ambiguity which function will be chosen if it will
be called.
If you have templates
// form 1
template Foo(int N) if (N & 1){} // A
On Monday, 23 April 2018 at 13:32:49 UTC, Alex wrote:
On Monday, 23 April 2018 at 10:57:59 UTC, Simen Kjærås wrote:
There is no official definition. That's because some natural
rewrite rules are implied, which are very general, I assume...
How official do you want it to be? That's the only
On Monday, 23 April 2018 at 08:07:52 UTC, Alex wrote:
On Monday, 23 April 2018 at 07:49:39 UTC, Simen Kjærås wrote:
That's not the definition of lowering used elsewhere, and so
will lead to confusion and misunderstanding. I would strongly
suggest you rethink your definition of lowering.
On Monday, 23 April 2018 at 04:58:38 UTC, Alex wrote:
On Monday, 23 April 2018 at 00:26:23 UTC, Simen Kjærås wrote:
There is a limited set of lowerings, and they are defined in
the language, not in user code. They include operator
overloading (where `a op b` is translated to
On Sunday, 22 April 2018 at 19:27:24 UTC, Alex wrote:
On Sunday, 22 April 2018 at 18:25:29 UTC, Simen Kjærås wrote:
No lowering occurs here. A lowering is when the compiler takes
one piece of syntax and replaces it with a different one,
usually one that's more verbose.
In a way, it's kind of
On Saturday, 21 April 2018 at 21:10:29 UTC, Alex wrote:
On Saturday, 21 April 2018 at 19:51:05 UTC, Simen Kjærås wrote:
On Saturday, 21 April 2018 at 11:23:33 UTC, Alex wrote:
So, do you mean, that the constraint belongs to the interface
of a template?
Not necessarily - it depends on what
On Saturday, 21 April 2018 at 11:23:33 UTC, Alex wrote:
On Thursday, 19 April 2018 at 17:55:47 UTC, Simen Kjærås wrote:
Your first example defines two templates (which are overloads
of the same name), the second only one. There's no ambiguity
there.
So, do you mean, that the constraint
On Thursday, 19 April 2018 at 13:57:04 UTC, Simen Kjærås wrote:
On Tuesday, 17 April 2018 at 14:22:27 UTC, Arafel wrote:
Hi!
Is there any way to get the full set of templates that are
"overloaded" (in my case, based on constraints)?
Currently, there is no way (that I've found, at least) to
On Thursday, 19 April 2018 at 14:16:21 UTC, Alex wrote:
On Thursday, 19 April 2018 at 13:57:04 UTC, Simen Kjærås wrote:
Currently, there is no way (that I've found, at least) to do
this. If you have a workaround, that's great, but there really
should be a way - probably __traits(getOverloads).
On Tuesday, 17 April 2018 at 14:22:27 UTC, Arafel wrote:
Hi!
Is there any way to get the full set of templates that are
"overloaded" (in my case, based on constraints)?
Currently, there is no way (that I've found, at least) to do
this. If you have a workaround, that's great, but there
On Thursday, 19 April 2018 at 10:10:41 UTC, Chris Katko wrote:
That makes sense why transpose wouldn't work for my arrays!
So you're saying if I used [][] (dynamic array) that's a range
of ranges, and it would work?
Yup. Static arrays can't be ranges, since popFront must mutate
the length,
On Wednesday, 18 April 2018 at 06:54:29 UTC, Chris Katko wrote:
I need to rotate an array by 90 degrees, or have writefln
figure that out.
I need, say:
0 4 5 6
0 0 0 0
0 0 0 0
0 0 0 0
But it's outputting:
0 0 0 0
4 0 0 0
5 0 0 0
6 0 0 0
int [4][4] data;
file.writeln(format("%(%-(%d
On Wednesday, 18 April 2018 at 01:12:33 UTC, Chris Katko wrote:
My only questions are:
[snip]
How's about this one:
import std.stdio : writefln;
struct data_to_access_t
{
int tacos;
}
class Abc(T, alias Fn) {
T data;
this(T data) {
this.data = data;
}
void
On Tuesday, 17 April 2018 at 03:55:55 UTC, Chris Katko wrote:
What I want:
class viewport_t
{
int x,y,w,h;
}
class dialog_t
{
int x,y;
this( int x, int y, delegate void (viewport_t) on_draw )
{
this.x = x;
this.y = y;
this.execute = execute;
}
void
On Saturday, 14 April 2018 at 08:20:51 UTC, bauss wrote:
The problem is I can't pragma(msg) the code I want to mixin
manually since all mixins are dynamically generated. That's why
my only way is to do it within that static foreach.
Wat.
So the compiler is able to generate the string you
On Monday, 9 April 2018 at 11:33:56 UTC, Alex wrote:
On Monday, 9 April 2018 at 09:20:42 UTC, Simen Kjærås wrote:
Nope. Something along the lines of __traits(getSource, arg)
has been discussed occasionally.
Is this available somehow? And/or do you have a link to the
discussion, maybe?
On Monday, 9 April 2018 at 08:27:50 UTC, Per Nordlöw wrote:
Is it possible to get the source expression sent to a lazy
function?
Nope. Something along the lines of __traits(getSource, arg) has
been discussed occasionally.
For lazy what you're asking is impossible, since the compiler
On Saturday, 7 April 2018 at 13:31:01 UTC, Timoses wrote:
In the end I would like to accomplish the following:
Provide access to contained bitfields and members of a struct
in the order they
appear in the struct via an index.
The behavior of Type.tupleof in D seems a bit unfinished - they
On Wednesday, 4 April 2018 at 15:49:31 UTC, Vladimirs Nordholm
wrote:
if (is(T == A) || is(T == B) || is(T == Enum))
if (is(T : Enum))
--
Simen
On Wednesday, 4 April 2018 at 10:11:37 UTC, Timoses wrote:
Example:
```
class A
{
immutable int i;
this(){}
}
class B : A
{
this()
{
this.i = 3;
}
}
void main()
{
auto b = new B;
}
```
throws:
Error: constructor `onlineapp.A.this` missing initializer for
On Wednesday, 28 March 2018 at 23:02:53 UTC, Chris Katko wrote:
There's many things that can be done to make the code easier to
follow. These lines:
static if (!hasPosition)
{
assert(0, "Need to pass a position!");
}
Can be replaced with
On Wednesday, 28 March 2018 at 09:44:35 UTC, number wrote:
Is there a way to get the classname without specifying the
class in the first place as required by classinfo and
fullyQualifiedName? extracting it from __FUNCTION__ wouldn't
work outside a function, i.e. for a classfield, and 'this'
On Wednesday, 28 March 2018 at 07:45:59 UTC, Chris Katko wrote:
I have a static foreach that goes through the parameter list
and if it sees a class like "rotate", ideally, I want it to
mark a boolean "has_rotate=true"
Then simply later on, once I've parsed the list, I pick an
output path:
On Tuesday, 27 March 2018 at 12:17:58 UTC, Ellie Harper wrote:
Sorry if this is a stupid question, but is there something
special required to call Appender.clear? When I attempt even
just a simple use I am getting compile errors relating to
`template object.clear`.
From the documentation
On Monday, 26 March 2018 at 09:46:57 UTC, Nicholas Wilson wrote:
Have a look at Rebindable:
https://dlang.org/phobos/std_typecons.html#rebindable
Allow me to quote from aliak's post:
what I'm looking for is a Rebindable implementation that's for
value types
As can be surmised from the
On Monday, 26 March 2018 at 08:29:31 UTC, Brian wrote:
Rust sample code:
#[cfg(name = "users")]
PHP sample code:
/*
@Table(name = "users")
*/
Java sample code:
@Table(name = "users")
How to use dlang get key name?
If I understand your question correctly:
struct Table {
string name;
On Sunday, 25 March 2018 at 23:00:11 UTC, Simen Kjærås wrote:
On Sunday, 25 March 2018 at 21:26:57 UTC, aliak wrote:
struct Optional(T) {
Unqual!T value;
opAssign(T t) {
value = cast(Unqual!T)(t);
}
}
Consider this case:
Optional!(immutable int) a = some(3);
immutable int* p =
a =
On Sunday, 25 March 2018 at 21:26:57 UTC, aliak wrote:
struct Optional(T) {
Unqual!T value;
opAssign(T t) {
value = cast(Unqual!T)(t);
}
}
Consider this case:
Optional!(immutable int) a = some(3);
immutable int* p =
a = some(5);
Clearly the above code shouldn't compile - you can't
On Thursday, 22 March 2018 at 13:16:00 UTC, berni wrote:
Part of my code looks like this:
out (result)
{
if (result==true)
{
lots of assertions...
}
}
I would prefer an early exit like:
out (result)
{
if (result==false) return;
lots of assertions...
}
Is this possible
On Wednesday, 21 March 2018 at 15:36:01 UTC, Márcio Martins wrote:
Hi!
How do I get past this?
static struct X {
int x;
private enum T = 1;
private alias M = string;
}
foreach (Member; __traits(allMembers, X)) {
pragma(msg, __traits(getProtection, __traits(getMember,
On Wednesday, 21 March 2018 at 12:01:01 UTC, Quantum Nerd wrote:
How is it possible that b in main() and r in the function
occupy the same memory?
I would expect the same behaviour as with c.
Can somebody with more experience shed some light on this?
I'm pretty sure you're seeing NRVO -
On Wednesday, 21 March 2018 at 11:30:28 UTC, Timoses wrote:
Hey,
I'm struggling to find a way to achieve this. I've looked
through std.algorithm but didn't find anything.. Maybe I'm
blind.
What I would like to do is filter out all spaces in a string
and change the front letter to lower
On Thursday, 15 March 2018 at 15:41:54 UTC, Robert-D wrote:
Why something like this doesn't compile (with or without the
cast on bb.dup)?
struct S {
string[string] aa;
S dup() inout pure {
return S(cast(string[string]) aa.dup);
}
}
struct SS {
S[] bb;
SS dup()
On Thursday, 15 March 2018 at 12:00:08 UTC, Robert-D wrote:
I want the function to create a mutable copy from a const or a
imutable
Like this:
void main() {
const S s = S(["": ""]);
S b = s.dup();
}
How can i do that?
In that case, the problem is that you also have to .dup the aa:
On Thursday, 15 March 2018 at 11:18:48 UTC, Robert-D wrote:
struct S {
string[string] aa;
S dup() inout pure {
return S(aa);
}
}
void main() {
auto s = S(["": ""]);
s.dup();
}
Result:
Error: cannot implicitly convert expression this.aa of type
On Thursday, 15 March 2018 at 10:16:49 UTC, Andrey wrote:
Hello, is there way to declare read only field for class type
with ability to call inner non constant methods? i.e.:
class A {
int value = 12;
void updateValue() {
value = 13;
}
}
class B {
const A a;
On Tuesday, 13 March 2018 at 18:55:35 UTC, Marc wrote:
I want to basically make this work:
auto l = new List();
l += 5;
I managed to do this:
class List
{
int[] items;
ref List opBinary(string op)(int rhs) if(op == "+")
{
items ~= rhs;
On Monday, 12 March 2018 at 10:37:00 UTC, Alex wrote:
Sure, you have.
https://dlang.org/spec/struct.html#assign-overload
Point #4.
In this case,
ref S opAssign(ref S rhs)
{
return this;
}
True. Can you fix these, too?
struct S {
S* ptr;
this(int dummy) {
ptr =
}
On Monday, 12 March 2018 at 08:59:49 UTC, Alex wrote:
An incomplete type is perfectly ok, so there should be no
problem with a pointer of the same type inside a struct.
If accidentally the pointer refers "this", then it must have
been set after construction. As before construction the value
of
On Saturday, 10 March 2018 at 17:43:06 UTC, Simen Kjærås wrote:
I'm not sure how fixable this is, but I am sure that there's
plenty of benefit to being able to write code like this:
struct S {
int n, m;
SomeType!(() => n + m) a;
}
over this:
struct S {
int n, m;
auto a() {
On Sunday, 11 March 2018 at 12:05:56 UTC, aliak wrote:
* aliasOf!int!"string" // multiple ! arguments are not allowed
* (aliasOf!int)!"string" // error c-style cast
* aliasOf!int.aliasOf!"string" // template isAliasOf(alias a)
does not have property 'isAliasOf
Yeah, that's a little hole in
On Friday, 9 March 2018 at 23:34:56 UTC, Mike Franklin wrote:
On Friday, 9 March 2018 at 14:46:04 UTC, Simen Kjærås wrote:
1) Wrong return type:
unittest {
S s;
auto a = s.field;
// Fails - typeof(a) is Property!((get) => this.n, (set)
=> this.n = set)
assert(is(typeof(a) ==
On Friday, 9 March 2018 at 19:24:03 UTC, Nordlöw wrote:
I'm looking for a function (that probably should be placed in
std.meta) named something like `areEqual` that checks whether
all it's arguments are equal or not.
Is there such as function already in Phobos?
My usage is
static if
On Friday, 9 March 2018 at 17:47:46 UTC, Timoses wrote:
To retrieve the member names the following (and filtering for
only the functions) does the job:
alias members = aliasSeqOf!([__traits(allMembers, S)]);
This can be simplified to
alias members = Alias!(__traits(allMembers, S));
On Friday, 9 March 2018 at 01:22:15 UTC, Mike Franklin wrote:
* binary assignment operators (e.g. +=)
* unary assignment operators (e.g. ++)
* @safe, @nogc, and -betterC compatible
* at least as good code generation as that proposed in the DIP
when optimizations are enabled.
* And should be
On Wednesday, 7 March 2018 at 10:10:49 UTC, J-S Caux wrote:
On Wednesday, 7 March 2018 at 08:04:36 UTC, Simen Kjærås wrote:
auto log(T)(Complex!T x) {
import std.math : log;
return Complex!T(log(abs(x)), arg(x));
}
Yes indeed I can do this, but isn't this inefficient as
compared to
On Wednesday, 7 March 2018 at 07:42:37 UTC, J-S Caux wrote:
Simple question: how do I get the log of a complex number?
If I try the simple
logtest = log(complex(1.0, 2.0))
I get the compiler error
Error: function core.stdc.math.log(double x) is not callable
using argument types
On Wednesday, 28 February 2018 at 18:23:04 UTC, Jiyan wrote:
The nodes are only allocated over malloc(). So i have to take
care of the initialisation myself.
The problem is, that i found out by debugging, that it seems
that when i call val.opAssign(op) in constructNodeFrom(), there
isn't any
On Friday, 2 March 2018 at 10:01:34 UTC, Jonathan M Davis wrote:
On Friday, March 02, 2018 09:44:20 psychoticRabbit via
Digitalmars-d-learn wrote:
trying to do this C code, in D, but getting error:
"Error: assignment cannot be used as a condition, perhaps `==`
was meant?"
any help much
On Thursday, 1 March 2018 at 08:31:05 UTC, Piotr Mitana wrote:
For some reason this is true:
slide!(Yes.withPartial)([1, 2, 3, 4, 5], 3).array == [[1, 2,
3], [2, 3, 4], [3, 4, 5]]
Shouldn't it rather return [[1], [1, 2], [1, 2, 3], [2, 3, 4],
[3, 4, 5], [4, 5], [5]], or at least [[1, 2, 3],
On Monday, 26 February 2018 at 13:09:40 UTC, ParticlePeter wrote:
Thanks for clarification, unfortunately your suggestion doesn't
work.
Since when is alias this = something; supposed to work?
alias Common.this this; doesn't work as well and following also
not:
struct Baz {
Foo foo;
alias
On Wednesday, 21 February 2018 at 14:29:38 UTC, ixid wrote:
I do not understand what is happening here, I tried to wrote
what I thought would be the answer. If someone could explain
that would be great. I wrote this code:
struct Foo2(T, S) {
T bar;
this(S s) {
bar = s.to!T;
}
}
On Wednesday, 21 February 2018 at 14:11:10 UTC, ParticlePeter
wrote:
struct Foo(T) {
T bar;
this(S)(S s) {
bar = convert(s);
}
}
auto foo = Foo!int(some_float);
this works because S is deduced as typeof(some_float), but how
would I instantiate the struct without relying on auto
On Wednesday, 21 February 2018 at 06:45:14 UTC, thorstein wrote:
Hi,
I'm going circles... ;) I read a string that contains an array
of unknown dimension like:
a = [1,2,3,4] or
a = [[1,2],[3,4]] or
a = [[[1,2],[3,4]],[[5,6],[7,8]]]
With that I want to perform specified operations e.g. also
On Tuesday, 20 February 2018 at 14:34:53 UTC, bauss wrote:
Would there be a reason why this wouldn't be a good
implementation?
What is the intended use case for this? The main feature seems to
be an ability to have read-only members, which is nice. Are there
other benefits?
If so what
On Monday, 19 February 2018 at 14:20:16 UTC, Basile B. wrote:
I had never used Checked and i discover that strangely there's
no hook for opAssign. onLowerBound and onUpperBound works for
+=, -=, *=, /=, %=, ^^=, &=, |=, ^=, <<=, >>=, and >>>=. But
since init is 0, += works:
Ah, thanks. Filed
On Monday, 19 February 2018 at 13:33:34 UTC, rikki cattermole
wrote:
https://dlang.org/phobos/std_experimental_checkedint.html#.Checked.min
Can't seem to get that to work, so I assumed it's not meant to be
used that way:
import std.experimental.checkedint;
struct MyHook {
enum min(T) =
On Monday, 19 February 2018 at 12:58:45 UTC, Marc wrote:
I'm pretty sure something could be done with Ada's type range
but what we could do using D?
We can easily define a range type in D. The simple example below
probably has awful performance and many holes, but outlines the
basic idea. It
On Monday, 12 February 2018 at 09:58:13 UTC, Alex wrote:
On Monday, 12 February 2018 at 09:37:56 UTC, Simen Kjærås wrote:
Not really, since D doesn't have a concept of an address
associated with a type, only with instances of it. So when you
use a static array, the address is hard-coded.
On Monday, 12 February 2018 at 09:10:52 UTC, Alex wrote:
A more extreme example: You have a compiled library, and some
.di (header) files. In one of those files is this code:
struct S {
static int[] arr;
void foo();
}
Now how should Typedef go about making foo() do the right
thing?
On Sunday, 11 February 2018 at 19:33:23 UTC, Alex wrote:
On Sunday, 11 February 2018 at 15:18:11 UTC, Simen Kjærås wrote:
Basically, Typedef looks like this:
struct Typedef(T) {
T _payload;
// Forward method calls, member access, etc, to _payload.
}
If T looks like this:
struct T {
On Monday, 12 February 2018 at 08:35:05 UTC, Nathan S. wrote:
For example in std.container.rbtree:
---
auto equalRange(this This)(Elem e)
{
auto beg = _firstGreaterEqual(e);
alias RangeType = RBRange!(typeof(beg));
if (beg is _end || _less(e, beg.value))
On Sunday, 11 February 2018 at 01:32:52 UTC, Alex wrote:
On Saturday, 10 February 2018 at 02:55:26 UTC, Alex wrote:
bug filed
https://issues.dlang.org/show_bug.cgi?id=18416
Basically, Typedef looks like this:
struct Typedef(T) {
T _payload;
// Forward method calls, member access,
On Saturday, 10 February 2018 at 13:18:28 UTC, Alex wrote:
Do I overlook something?
/// --- code --- ///
import std.typecons;
void main(){}
static assert(!__traits( compiles, E()));
static assert(!__traits( compiles, MyE())); // line 6
struct E
{
size_t dummy;
@disable
On Friday, 2 February 2018 at 14:29:34 UTC, H. S. Teoh wrote:
Its semantics are not broken; it's just harder to use. Due to
const transitivity, it's an all-or-nothing deal. .tailConst
gives us the middle ground.
If the semantics of const means that users will have to write
.tailConst all
On Thursday, 1 February 2018 at 18:58:15 UTC, H. S. Teoh wrote:
However, if we go back to the idea of tail-const, we could
potentially eliminate the need for casts and also avoid
breaking immutable. Basically, the problem with writing
const(RefCounted!T) is that it's a one-way street: on the
On Thursday, 1 February 2018 at 11:51:11 UTC, aliak wrote:
Is there a way to do this:
import std.stdio;
void main()
{
alias f = (a) => (b) => a * b;
f(2)(3).writeln;
}
The problem here is the outer lambda doesn't know what type the
inner lambda is. We can rewrite this a bit:
auto
On Wednesday, 31 January 2018 at 01:45:57 UTC, H. S. Teoh wrote:
I haven't thought through it carefully, but if .headConst is a
viable solution to the head-const problem, then conceivably we
could also extend it to deal with immutable payloads too. Then
we could go from, say,
On Wednesday, 31 January 2018 at 01:45:57 UTC, H. S. Teoh wrote:
.headConst
.headMutable. :p Head-const is something we generally want to
avoid.
--
Simen
On Tuesday, 30 January 2018 at 17:41:53 UTC, jsako wrote:
So what's considered the best alternative to void pointers in D
if you don't want to use objects? Make a tagged Union of all
possible datatypes in the struct? Have a Byte array and cast
that instead of a void pointer? Some sort of magic
On Tuesday, 30 January 2018 at 14:01:00 UTC, bauss wrote:
unittest {
auto a = foo(); // This should fail, because a is
never used.
No it shouldn't. It is assigned to a variable, as the constraint
said.
// This should also fail, because b is never used actually
used
On Tuesday, 30 January 2018 at 11:36:25 UTC, Jonathan M Davis
wrote:
[nope]
Thanks. It's what I thought, though not what I wanted.
IIRC, the Weka guys wanted to be able to have attributes tell
the compiler stuff so that it could yell at the programmer when
appropriate, so I think that there
Is there a way to get a compile error when returning a temporary
from a function and then not assigning it to a variable or
passing it to a different function? E.g:
struct S {
int[] a;
void morph() {}
}
@warnOnDiscard
S foo() {
return S([1,2,3]);
}
unittest {
auto a = foo();
On Monday, 29 January 2018 at 11:36:26 UTC, aliak wrote:
You don't want to mutate const elements anyway. It would be
breaking a promise that other parts of the program may be
depending on. I would return a filtered-out range:
Right, I want to mutate the range though, not the elements. So
On Monday, 29 January 2018 at 09:23:55 UTC, Sobaya wrote:
I found a strange behavior.
class A {
void opAssign(int v) {}
}
class Test {
A a;
this() {
a = new A(); // removing this causes compile error.
a = 3; // cannot implicitly convert expression `3` of
`int` to
On Friday, 26 January 2018 at 15:33:03 UTC, aliak wrote:
On Friday, 26 January 2018 at 14:35:25 UTC, Meta wrote:
On Friday, 26 January 2018 at 14:16:04 UTC, aliak wrote:
1) I've seen some phobos code checking for assignability like
this:
is(typeof(range.front = false))
... is that an
On Friday, 26 January 2018 at 20:43:05 UTC, Fra Mecca wrote:
What should I do now?
I am undecided between:
- commenting on the bug tracker and close the bug
- link the pr 6056 on the bug tracker
- leaving it be
Leaving a comment on the bug with a link to the PR, and marking
the bug resolved
On Friday, 26 January 2018 at 14:16:04 UTC, aliak wrote:
It basically steps through in a stride and sets the checkpoints
to false.
C++:
template N>
void mark(It begin, It end, N step) {
assert(begin != end)
*begin = false;
while (end - begin > step) {
begin = begin + step;
On Friday, 26 January 2018 at 20:08:19 UTC, Dechcaudron wrote:
So I'm trying to get this to compile:
```
static foreach (alias member; getSymbolsByUDA!(typeof(this),
Serialize))
serializeMember!member(bundle);
```
And I'm getting the following error: value of 'this' is not
On Saturday, 20 January 2018 at 14:31:59 UTC, Sobaya wrote:
How can I wrap function whose arguments contain both ref and
normal like 'func' ?
With normal 'Args', x is not increased because x is copied when
passed to opDispatch.
If I write 'ref Args' in opDispatch's argument, it fails
because
On Friday, 19 January 2018 at 11:02:01 UTC, tipdbmp wrote:
The following seems to work in C++, but errors in D, why is
that?
int foo(int* num) {
{
static int x = 10;
x += 1;
*num += x;
}
{
static int x = 20; // error: foo.x is already defined
in
201 - 300 of 311 matches
Mail list logo