"Timon Gehr" 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, even if not
On Wed, 01 Jun 2011 10:32:10 -0400, Timon Gehr 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...
It's somewhat like st
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 i
On Tue, 31 May 2011 19:32:59 -0400, Nick Sabalausky wrote:
"Nick Sabalausky" wrote in message
news:is3tk5$1j2n$1...@digitalmars.com...
"Timon Gehr" 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
Nick Sabalausky wrote:
> "bearophile" 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 mini
"bearophile" 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?
>
If it is indee
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
"Nick Sabalausky" 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/
>
Thank
"Nick Sabalausky" wrote in message
news:is3tk5$1j2n$1...@digitalmars.com...
> "Timon Gehr" 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 test
"Timon Gehr" wrote in message
news:is3rb5$1g32$1...@digitalmars.com...
>
> Nick Sabalausky wrote:
>>
>> "Timon Gehr" 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.
Nick Sabalausky wrote:
>"Timon Gehr" 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 (numPo
"Timon Gehr" 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) {
>> for
Nick Sabalausky wrote:
>
> "Timon Gehr" 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!(numPo
"Timon Gehr" 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 this s
> 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
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
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/type
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 version
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)
>
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 conve
"Jonathan M Davis" wrote in message
news:mailman.494.1306830186.14074.digitalmar...@puremagic.com...
> Okay. According to a recent post on the Announce group, Walter wants all
> articles for the contest to be posted to the D newsgroup with [Submission]
> in
> the subject line, so I'm reposting t
"Lars T. Kyllingstad" 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 entry:
>>
>> http:
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
23 matches
Mail list logo