Nick Sabalausky wrote:
bearophile bearophileh...@lycos.com wrote in message
news:is45u7$21vq$1...@digitalmars.com...
Nick Sabalausky:
Error: template instance cannot use local 'np' as parameter to non-global
template addGizmosTo(int numPorts,bool isSpinnable)
Are you able to reduce this to
On Tue, 31 May 2011 19:32:59 -0400, Nick Sabalausky a@a.a wrote:
Nick Sabalausky a@a.a wrote in message
news:is3tk5$1j2n$1...@digitalmars.com...
Timon Gehr timon.g...@gmx.ch wrote in message
news:is3rb5$1g32$1...@digitalmars.com...
It works for me. Are you sure you did not accidentally break
Steven Schveighoffer wrote:
I think there are certain special situations where you can use
typeof(this). For example, as the return type for a static method.
*looks for doc* Couldn't find any documentation on it...
It's somewhat like static this, which is inflexible in how you write it.
On Wed, 01 Jun 2011 10:32:10 -0400, Timon Gehr timon.g...@gmx.ch wrote:
Steven Schveighoffer wrote:
I think there are certain special situations where you can use
typeof(this). For example, as the return type for a static method.
*looks for doc* Couldn't find any documentation on it...
Timon Gehr timon.g...@gmx.ch wrote in message
news:is5iha$1e2k$1...@digitalmars.com...
It is not documented in detail but it is there =).
See: http://www.digitalmars.com/d/2.0/declaration.html
1. typeof(this) will generate the type of what this would be in a
non-static
member function,
On Tue, 31 May 2011 02:36:58 -0400, Nick Sabalausky wrote:
Getting in just under the wire here. I seem to have misjudged the scope
of my topic, it ended up a bit large... Anyway, here's my entry:
http://www.semitwist.com/articles/EfficientAndFlexible/SinglePage/
Nice article. :) Some of
Lars T. Kyllingstad public@kyllingen.NOSPAMnet wrote in message
news:is2aah$29pf$1...@digitalmars.com...
On Tue, 31 May 2011 02:36:58 -0400, Nick Sabalausky wrote:
Getting in just under the wire here. I seem to have misjudged the scope
of my topic, it ended up a bit large... Anyway, here's my
Nick Sabalausky:
http://www.semitwist.com/articles/EfficientAndFlexible/SinglePage/
Regarding your addGizmos() in ex6_meta_flex3_runtimeToCompileTime1.d:
void addGizmos(int numPorts, bool isSpinnable, int numGizmos) {
// Dispatch to correct version of addGizmosTo.
// Effectively
bearophile wrote:
...
A shorter way to write it:
void addGizmos(int numPorts, bool isSpinnable, int numGizmos) {
foreach (np; TypeTuple!(1, 2, 3, 5, 10))
if (numPorts == np) {
foreach (b; TypeTuple!(true, false))
if (isSpinnable == b)
On 5/31/11 6:05 PM, bearophile wrote:
Nick Sabalausky:
http://www.semitwist.com/articles/EfficientAndFlexible/SinglePage/
Regarding your addGizmos() in ex6_meta_flex3_runtimeToCompileTime1.d:
void addGizmos(int numPorts, bool isSpinnable, int numGizmos) {
// Dispatch to correct
Ary Manzana wrote:
Why you need a type tuple? Can't you do:
foreach(np; [1, 2, 3, 5, 10])
That is a runtime foreach, so no. If the argument is a TypeTuple, the compiler
evaluates the foreach as a static foreach, effectively duplicating all code in
its body and filling in the constants/types in
Timon Gehr:
Nice, but isSpinnable is always checked twice with your approach.
Right. But isn't the compiler able to optimize away this inefficiency?
I would like an explicit static foreach better though.
See:
http://d.puremagic.com/issues/show_bug.cgi?id=4085
Bye,
bearophile
Timon Gehr:
Nice, but isSpinnable is always checked twice with your approach.
Right. But isn't the compiler able to optimize away this inefficiency?
Nope. You don't get a guarantee from the language that your code will be
optimized
in a certain way.
That said, dmd/gdc are _not_ able to do
Timon Gehr timon.g...@gmx.ch wrote in message
news:is2lts$2fcn$1...@digitalmars.com...
@Article: A very good read, it does not get boring even though it is quite
long. I
like it.
Thanks :)
Small nitpick:
mixin(declareInterface(IGizmo, Gizmo!(numPorts, isSpinnable)));
It seems like
Nick Sabalausky wrote:
Timon Gehr timon.g...@gmx.ch wrote in message
news:is2lts$2fcn$1...@digitalmars.com...
@Article: A very good read, it does not get boring even though it is quite
long. I
like it.
Thanks :)
Small nitpick:
mixin(declareInterface(IGizmo, Gizmo!(numPorts,
Timon Gehr timon.g...@gmx.ch wrote in message
news:is2lts$2fcn$1...@digitalmars.com...
bearophile wrote:
...
A shorter way to write it:
void addGizmos(int numPorts, bool isSpinnable, int numGizmos) {
foreach (np; TypeTuple!(1, 2, 3, 5, 10))
if (numPorts == np) {
Nick Sabalausky wrote:
Timon Gehr timon.g...@gmx.ch wrote in message
news:is2lts$2fcn$1...@digitalmars.com...
bearophile wrote:
...
A shorter way to write it:
void addGizmos(int numPorts, bool isSpinnable, int numGizmos) {
foreach (np; TypeTuple!(1, 2, 3, 5, 10))
if (numPorts ==
Timon Gehr timon.g...@gmx.ch wrote in message
news:is3rb5$1g32$1...@digitalmars.com...
Nick Sabalausky wrote:
Timon Gehr timon.g...@gmx.ch wrote in message
news:is2lts$2fcn$1...@digitalmars.com...
@Article: A very good read, it does not get boring even though it is
quite
long. I
Nick Sabalausky a@a.a wrote in message
news:is3tk5$1j2n$1...@digitalmars.com...
Timon Gehr timon.g...@gmx.ch wrote in message
news:is3rb5$1g32$1...@digitalmars.com...
It works for me. Are you sure you did not accidentally break some other
part of
your __traits(compiles,...) ?
My minimal
Nick Sabalausky a@a.a wrote in message
news:is22gk$1v03$1...@digitalmars.com...
Getting in just under the wire here. I seem to have misjudged the scope of
my topic, it ended up a bit large... Anyway, here's my entry:
http://www.semitwist.com/articles/EfficientAndFlexible/SinglePage/
Thanks
Nick Sabalausky:
Error: template instance cannot use local 'np' as parameter to non-global
template addGizmosTo(int numPorts,bool isSpinnable)
Are you able to reduce this to a minimal test case?
Bye,
bearophile
bearophile bearophileh...@lycos.com wrote in message
news:is45u7$21vq$1...@digitalmars.com...
Nick Sabalausky:
Error: template instance cannot use local 'np' as parameter to non-global
template addGizmosTo(int numPorts,bool isSpinnable)
Are you able to reduce this to a minimal test case?
22 matches
Mail list logo