On Saturday, 22 November 2014 at 20:57:07 UTC, WhatMeWorry wrote:
auto bottom = NestedBottom(2, ['d','o','g']);
That 'auto' is the problem. You want 'this.bottom = ...' instead.
Slightly simpler:
struct SomeType(K, V) {}
alias X(V) = V;
alias X(V, K...) = SomeType!(K[0], X!(V, K[1 .. $]));
That's a recurring pattern to get used to: aliasing away to one
of the parameters in a terminal and/or degenerate case. Also:
that an empty tuple matches no parameter
In the original you are casting an int to a pointer type, which
is legitimate (although rarely a good idea). The other side of
the matter is simply precedence.
cast(T)a.b;
Is really the same as:
cast(T)(a.b);
There's Adam Ruppe's excellent D Cookbook available here:
https://www.packtpub.com/application-development/d-cookbook
And since you specifically said web developer I hope you're
looking at vibe.d:
http://vibed.org/
class A
{
string getName(this Klass)()
{
return Klass.stringof;
}
}
class B : A
{}
void main()
{
import std.stdio;
auto a = new A;
auto b = new B;
writeln(a.getName());
writeln(b.getName());
}
##
This
On Wednesday, 20 August 2014 at 15:17:52 UTC, Ola Fosheim Gr
wrote:
non-static nested functions are effectively delegates as it
needs a context pointer to parent stack frame.
Only if it is recursive.
Or if it refers to any state of the parent function.
On Friday, 27 June 2014 at 07:43:27 UTC, Uranuz wrote:
I don't know why I use D enough long but I did not remember
this fact.
Sometimes we get spoiled by all the amazing/nifty things that do
work, and expect comparable things like this to Just Work. To be
honest, at first I didn't see any
On Friday, 27 June 2014 at 14:27:46 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
Try this:
Get out of my head!
On Friday, 27 June 2014 at 05:26:09 UTC, Puming wrote:
On Thursday, 26 June 2014 at 08:02:24 UTC, bearophile wrote:
Puming:
I'm using scriptlike, which imports everything from
std.process for convienience, but I also need to import
another module, which contains a class `Config`, it
On Thursday, 26 June 2014 at 11:07:37 UTC, Rene Zwanenburg wrote:
They won't. Same for module destructors.
If you need those to work, another option is to throw some
custom Exception type which is only caught in main.
I really wish this wasn't the answer, but for some programs I've
had to
UDA's are compile-time metadata associated with a specific
declaration. So in something like:
@foo int x;
The @foo is attached to x, but is not part of the type.
version(DigitalMars) version = DMDAsm;
version(LDC) version = DMDAsm;
version(DMDAsm) asm {
//dmd/ldc asm here
}
version(GDC) asm {
//gdc asm here
}
http://dlang.org/version.html#VersionSpecification
On Wednesday, 25 June 2014 at 17:21:21 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
The term attribute is a bit confusing, especially since
property is
also used in the language to refer to something completely
different. A
better term is perhaps annotation. The @foo is an annotation
on x,
On Saturday, 7 June 2014 at 02:23:18 UTC, Andrew Edwards wrote:
This function now works for all types except dstring. This
remains a problem I cannot figure out. The error code is as
follows:
$ rdmd -unittest textnext
/usr/share/dmd/src/phobos/std/conv.d(3293): Error: cannot
modify
On Friday, 6 June 2014 at 23:44:04 UTC, Evan Davis wrote:
Hello,
I'm looking to use the Tuple type as a way of generating types
to represent data in a send recieve connection pair. I created
a template to try this:
template s_to_c(UDP packetType) {
static if (packetType ==
On Saturday, 7 June 2014 at 03:21:49 UTC, Andrew Edwards wrote:
Wow. Sometimes you really cannot see the things you type no
matter how long you stare at it. Thank you soo much.
No problem. I only noticed when I re-typed it by hand to study
the flow, and instinctively added the else out of
On Saturday, 31 May 2014 at 22:45:32 UTC, bearophile wrote:
Chris Nicholson-Sauls:
Good... I was starting to fear I was the only one.
In general you can't fix the names in a language because you
always find someone that likes the ones present :) I think
enum is a bad name for the purpose
On Sunday, 1 June 2014 at 22:26:42 UTC, Vlad Levenfeld wrote:
I was pretty happy to find that I could use mu and sigma when
writing statistical routines, but I've found that for more
obscure non-ascii characters the support is hit or miss. For
example, none of the subscripts are valid
On Saturday, 31 May 2014 at 22:13:35 UTC, monarch_dodra wrote:
On Saturday, 31 May 2014 at 21:21:59 UTC, Paul D Anderson wrote:
'enum' as a manifest constant keyword has been an unpopular
decision from its introduction. Everybody agrees that it
should be changed. Everybody but Walter
I find
On Sunday, 6 April 2014 at 03:28:50 UTC, dnspies wrote:
On Sunday, 6 April 2014 at 03:23:17 UTC, Adam D. Ruppe wrote:
You can just set it to null. Then, next time you add anything
to it, a new one will be automatically created.
What about if I have a 2D array (ie int[][]) and I want to
On Sunday, 6 April 2014 at 02:21:35 UTC, dnspies wrote:
Is there a way to do a checked cast from a base type to an
enum-type (so that an exception is thrown if it fails)?
ie something like
enum x : dchar { A : 'a', B : 'b', C : 'c' };
x get_x() {
dchar r = get_char();
return cast(x)r;
On Tuesday, 19 November 2013 at 20:59:31 UTC, Dale Matthews wrote:
I'm brand new to D and I'm taking on a project. In the midst,
I've overloaded a whole load of operators for my Vec3 class.
Most seem to be working (I haven't tested them all yet) but
opEquals is refusing to be called. I've
This was a bug and has since been fixed, so the solution is
simply to update your compiler. If there is some reason you
can't (company required version, etc) then your cast() is sadly
probably the only way.
On Saturday, 16 November 2013 at 23:55:47 UTC, Jonathan M Davis
wrote:
If you're dealing with variadic arguments, then making the file
and line number
be template arguments is really your only solution. However, I
must warn you
that that will result in a new template instantation _every_
I had thought the pattern
alias B.funcA funcA;
was supposed to solve things like this, but it does not work.
Any reason it couldn't be made to? Or, for that matter, why
inherited members are not considered by interfaces in the first
place?
In related news, if you simply leave A out
There is the aforementioned extern(system), which is probably
your best bet. But I'm wondering if your design could seperate
the connection to IUnknown for non-Windows builds? Something
like this:
version(Windows) interface _Inter_ : IUnknown {}
else interface _Inter_ {}
// later
On Tuesday, 14 August 2012 at 22:31:16 UTC, bearophile wrote:
http://www.reddit.com/r/cpp/comments/y6gwk/norvigs_python_sudoku_solver_ported_to_c11/
http://nonchalantlytyped.net/blog/2012/08/13/sudoku-solver-in-c11/
His C++11 port is 316 lines long:
https://gist.github.com/3345676
How many
on the advantages side of using non-virtual interfaces.
-- Chris Nicholson-Sauls
right-click the message
header, and there will be a Cancel Message command way down toward the bottom.
-- Chris Nicholson-Sauls
Nicholson-Sauls
( key, elems ; sandbox ) {
writeln(`[`, key, `] `, elems);
}
}
// END CODE
-- Chris Nicholson-Sauls
Nicholson-Sauls
Sergey Kovrov wrote:
On 3/9/2009 8:50 PM, Chris Nicholson-Sauls wrote:
While not strictly intuitive, you could do this:
auto var = Rebindable!(const Foo)(new Foo);
assert(var.opDot !is null);
As 'opDot' returns the wrapped object (with const intact). The downside
to that, however
occasionally. In cases where I specifically
expect/encourage multilingual support/use, it can simplify matters
greatly, where those otherwise inefficient operations become common.
-- Chris Nicholson-Sauls
to Classes?
Not in the common case, no, but it can be useful at times. (Although,
most of the cases where I would use them involve parameter passing, so I
just use 'ref' arguments.)
-- Chris Nicholson-Sauls
Stewart Gordon wrote:
Chris Nicholson-Sauls wrote:
snip
Suggest: Array operation 'OP' not implemented for type T[].
Where OP is here '+' and T is here char.
It doesn't quite work like that. AIUI the only supported way of using
array operations is assigning the result to an array slice
*'.
I'm a physicist, not a computer scientist. :)
Which is a good thing, since D could use more experience from
non-programmers who need to program. That's a demographic that
occasionally (but never completely!) gets forgotten. I'm not exactly a
thirty-years guru, myself.
-- Chris Nicholson
Jarrett Billingsley wrote:
On Tue, Feb 3, 2009 at 3:44 PM, Chris Nicholson-Sauls
ibisbase...@gmail.com wrote:
The
second reason, is that before every allocation the garbage collector will
perform a collection run. This can actually be disabled (at least in
theory) if you plan on doing several
(?,X) a million
times, the cost of allocating one object is amortized into nearly nothing.)
-- Chris Nicholson-Sauls
a was resized in
place or not. Which is why slicing, albeit a fantastically useful
feature, has to be handled with care.
-- Chris Nicholson-Sauls ibisbasenji @ Google Mail
40 matches
Mail list logo