www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - recursive template sends dmd on vacation...

reply "Regan Heath" <regan netwin.co.nz> writes:
--[test34.d]--
import std.stdio;

template Blah(int a, alias B)
{
   mixin Blah!(a-1, B);
}

template Blah(int a:0, alias B)
{
   writefln(B);
}

void main()
{
   int a;
   mixin Blah!(5,a);
}

C:\Library\D\src\temp>dmd test34.d
test34.d(5): mixin test34.main.Blah!(5,a) Blah__5__10__Dmain1ai.Blah!(...)  
Blah_
_4__10__Dmain1ai.Blah!(3,a) Blah__3__10__Dmain1ai.Blah!(2,a)  
Blah__2__10__Dmain1
ai.Blah!(1,a) Blah__1__10__Dmain1ai.Blah!(0,a) matches more than one  
template de
claration

Regan
Mar 30 2005
next sibling parent reply "Regan Heath" <regan netwin.co.nz> writes:
On Wed, 30 Mar 2005 22:23:46 +1200, Regan Heath <regan netwin.co.nz> wrote:
 --[test34.d]--
 import std.stdio;

 template Blah(int a, alias B)
 {
    mixin Blah!(a-1, B);
 }

 template Blah(int a:0, alias B)
 {
    writefln(B);
 }

 void main()
 {
    int a;
    mixin Blah!(5,a);
 }

 C:\Library\D\src\temp>dmd test34.d
 test34.d(5): mixin test34.main.Blah!(5,a)  
 Blah__5__10__Dmain1ai.Blah!(...) Blah_
 _4__10__Dmain1ai.Blah!(3,a) Blah__3__10__Dmain1ai.Blah!(2,a)  
 Blah__2__10__Dmain1
 ai.Blah!(1,a) Blah__1__10__Dmain1ai.Blah!(0,a) matches more than one  
 template de
 claration
I forgot to say, at this point dmd continues to run, use cpu/memory and does not come back.. at least for as long as I cared to wait which was a minute or two. Regan
Mar 30 2005
next sibling parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Regan Heath schrieb am Wed, 30 Mar 2005 22:37:20 +1200:
 On Wed, 30 Mar 2005 22:23:46 +1200, Regan Heath <regan netwin.co.nz> wrote:
<snip>
 I forgot to say, at this point dmd continues to run, use cpu/memory and  
 does not come back.. at least for as long as I cared to wait which was a  
 minute or two.
Is there any way to call a programm with a given cycle-limit instead of the setitimer kludge? Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCTJP23w+/yD4P9tIRAiH4AKDBAzuC9tpgf7sXrXXhxvvfsKpXgQCgjezC 2tb/Un5E191UGt4vFH7Q8CM= =JjOi -----END PGP SIGNATURE-----
Mar 31 2005
prev sibling parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Regan Heath schrieb am Wed, 30 Mar 2005 22:37:20 +1200:
 On Wed, 30 Mar 2005 22:23:46 +1200, Regan Heath <regan netwin.co.nz> wrote:
 --[test34.d]--
 import std.stdio;

 template Blah(int a, alias B)
 {
    mixin Blah!(a-1, B);
 }

 template Blah(int a:0, alias B)
 {
    writefln(B);
 }

 void main()
 {
    int a;
    mixin Blah!(5,a);
 }

 C:\Library\D\src\temp>dmd test34.d
 test34.d(5): mixin test34.main.Blah!(5,a)  
 Blah__5__10__Dmain1ai.Blah!(...) Blah_
 _4__10__Dmain1ai.Blah!(3,a) Blah__3__10__Dmain1ai.Blah!(2,a)  
 Blah__2__10__Dmain1
 ai.Blah!(1,a) Blah__1__10__Dmain1ai.Blah!(0,a) matches more than one  
 template de
 claration
I forgot to say, at this point dmd continues to run, use cpu/memory and does not come back.. at least for as long as I cared to wait which was a minute or two.
I finally added the time-out code to DStress. http://dstress.kuehne.cn/nocompile/bug_20050330_A.d http://dstress.kuehne.cn/run/bug_20050330_B.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCb4Sz3w+/yD4P9tIRAtq8AJ0UrRkZQ4tPOIurI4Cb0gbdT9L0TACguSv0 U7ZcP7lEWypY3lgT75bVWdw= =SQgO -----END PGP SIGNATURE-----
Apr 27 2005
prev sibling parent reply "Walter" <newshound digitalmars.com> writes:
"Regan Heath" <regan netwin.co.nz> wrote in message
news:opsof4hwgy23k2f5 nrage.netwin.co.nz...
 --[test34.d]--
 import std.stdio;

 template Blah(int a, alias B)
 {
    mixin Blah!(a-1, B);
 }

 template Blah(int a:0, alias B)
 {
    writefln(B);
 }

 void main()
 {
    int a;
    mixin Blah!(5,a);
 }

 C:\Library\D\src\temp>dmd test34.d
 test34.d(5): mixin test34.main.Blah!(5,a) Blah__5__10__Dmain1ai.Blah!(...)
 Blah_
 _4__10__Dmain1ai.Blah!(3,a) Blah__3__10__Dmain1ai.Blah!(2,a)
 Blah__2__10__Dmain1
 ai.Blah!(1,a) Blah__1__10__Dmain1ai.Blah!(0,a) matches more than one
 template de
 claration
The recursive problem is now fixed, but the example isn't syntactically correct. This works: import std.stdio; template Blah(int a, alias B) { mixin Blah!(a-1, B); } template Blah(int a:0, alias B) { void foo() { writefln(B); } } void main() { int a = 3; mixin Blah!(5,a); foo(); }
May 09 2005
parent Sean Kelly <sean f4.ca> writes:
In article <d5pg0t$dqt$1 digitaldaemon.com>, Walter says...
The recursive problem is now fixed, but the example isn't syntactically
correct.
Related question--what is the recursion limit for template code? Is it something I could theoretically run up against calculating Fibonacci numbers at compile-time or anything like that? Sean
May 10 2005