On Sunday, 15 December 2013 at 23:38:57 UTC, comco wrote:
On Sunday, 15 December 2013 at 23:13:39 UTC, Jakob Ovrum wrote:
On Friday, 13 December 2013 at 12:01:28 UTC, comco wrote:
From client perspective, properties look like member
variables.
With (auto) ref, a generic function can catch a
On Sunday, 15 December 2013 at 23:13:39 UTC, Jakob Ovrum wrote:
On Friday, 13 December 2013 at 12:01:28 UTC, comco wrote:
From client perspective, properties look like member variables.
With (auto) ref, a generic function can catch a member
variable and read it and update it:
void swap(T
On Friday, 13 December 2013 at 12:01:28 UTC, comco wrote:
From client perspective, properties look like member variables.
With (auto) ref, a generic function can catch a member variable
and read it and update it:
void swap(T)(ref T a, ref T b) {...}
The client can use swap with member
On Friday, 13 December 2013 at 12:50:01 UTC, Nicolas Sicard wrote:
On Friday, 13 December 2013 at 12:10:02 UTC, comco wrote:
Imagine a world in which a simple 'if' has the semantics of a
static if, if the condition is evaluable at CT. Is this a
world you would rather live in?
te
Imagine a world in which a simple 'if' has the semantics of a
static if, if the condition is evaluable at CT. Is this a world
you would rather live in?
template Fac(int i) {
if (i == 0) { // static if; doesn't introduce scope
enum Fac = 1;
} else {
enum Fac = i * Fac!(i-1);
}
}
// If the condi
From client perspective, properties look like member variables.
With (auto) ref, a generic function can catch a member variable
and read it and update it:
void swap(T)(ref T a, ref T b) {...}
The client can use swap with member variables.
But he can't use this swap with class properties - they
On Sunday, 13 January 2013 at 11:26:57 UTC, monarch_dodra wrote:
Bearophile: Is this proposal a pure optimization trick, or is
there some functionality gains here. The only one I can think
of, is if "Foo!B" would fail to compile. Is this what you are
going for...?
Also:
//
template Ternar
On Saturday, 5 January 2013 at 10:37:31 UTC, bearophile wrote:
In some case I'd like a hypothetical static ternary operator
usable on types:
alias T = (U.sizeof <= 16) ?? ushort : size_t;
That is equivalent to:
static if (U.sizeof <= 16) {
alias T = ushort;
} else {
alias T = size_t;
On Thursday, 27 December 2012 at 21:21:24 UTC, Philippe Sigaud
wrote:
On Thu, Dec 27, 2012 at 9:01 PM, comco
wrote:
I wrote a simple template mixin to hold common operator
overloads:
mixin template VectorSpaceOpsMixin(Vector, Scalar, alias a,
alias b)
{
Vector opUnary(string op)() if
I wrote a simple template mixin to hold common operator overloads:
mixin template VectorSpaceOpsMixin(Vector, Scalar, alias a, alias
b)
{
Vector opUnary(string op)() if (op == "-") {
return Vector(-a, -b);
}
...
}
This works like this:
struct complex {
double a, b;
On Thursday, 29 November 2012 at 01:38:50 UTC, bearophile wrote:
comco:
Looks like a bug?
This is what DMD 2.061alpha prints, it doesn't crash:
...\dmd2\src\phobos\std\range.d(603): Error: static assert
"Cannot put a string into a LockingTextWriter"
...\dmd2\src\phobos\st
When trying to compile this code:
import std.stdio;
class A;
class B(T) : T {
}
void main() {
writeln(typeid(B!A));
}
I get this error: Assertion failure: '!scope' on line 358 in file
'toobj.c'.
Shouldn't it be more like: Error: class main.A unable to resolve
forward reference in definit
On Sunday, 25 November 2012 at 16:01:39 UTC, Ali Çehreli wrote:
Could you please create a bug report:
http://d.puremagic.com/issues/
Ali
Filed an issue 9078.
A!B(...) defines a struct A with B typed in as Method, so call
to method(s); is the same as B(string)
Why is that? Here method is an instance of the type Method, not
the type Method itself, so by saying `method(s)` we can't mean a
constructor. Something very strange happens...
I have a simple
I have the following snippet:
struct A(alias Method)
{
string s;
this(Method method) {
method(s); // 5
}
}
struct B
{
this(int i) { }
void opCall(string s) { }
}
void main() {
A!B(B(0));
}
This code fails to compile with the following errors:
test.d(5): Error:
On Monday, 24 September 2012 at 11:39:08 UTC, monarch_dodra wrote:
Oh. I think I just got what your "reassign" was meant to do. I
think I see it now. I guess it does work nice actually.
I'd say that unfortunately, your *new* reassign is making the
assumption that it is possible to grab a refe
On Monday, 24 September 2012 at 07:00:37 UTC, monarch_dodra wrote:
On Sunday, 23 September 2012 at 21:44:20 UTC, comco wrote:
[SNIP]
Now we can implement our rotate in terms of reassign:
void rotate(node* u) {
auto v = u.right;
reassign(u.right, v.left, u);
}
This works and is
On Sunday, 23 September 2012 at 21:42:54 UTC, comco wrote:
On Sunday, 23 September 2012 at 19:53:26 UTC, Philippe Sigaud
wrote:
monarch_dodra already answered, but since, I typed this, I may
as well
post it :)
On Sun, Sep 23, 2012 at 8:49 PM, comco
wrote:
For this program I'm getti
On Sunday, 23 September 2012 at 19:53:26 UTC, Philippe Sigaud
wrote:
monarch_dodra already answered, but since, I typed this, I may
as well
post it :)
On Sun, Sep 23, 2012 at 8:49 PM, comco
wrote:
For this program I'm getting an "Error: need 'this' to access
member
For this program I'm getting an "Error: need 'this' to access
member x" at line (*). Does that mean that we cannot alias a
property as an argument of a template mixin?
import std.stdio;
mixin template T(alias a) {
void f() {
writeln(a); // (*)
}
}
s
20 matches
Mail list logo