Circle Calculator Help

Timon Gehr timon.gehr at gmx.ch
Tue Jun 26 12:59:07 PDT 2012


On 06/26/2012 09:43 PM, Steven Schveighoffer wrote:
> On Tue, 26 Jun 2012 10:40:18 -0400, Alexander
> <alexander at alexandermohn.com> wrote:
> ...
>> //Wait
>> void wait()
>> {
>>     writefln ("Type A to continue!");
>>     exittest();
>> }
>>
>> //Exit tester
>> void exittest()
>> {
>>     char[] a;
>>     stdin.readln(a);
>>     if (a == "A")
>>     {
>>         exit();
>>     }
>>     else
>>     {
>>         wait();
>>     }
>> }
>
> Hm... interesting code here :)
>
> This is not horrible, just... weird.
>

It is functional style. ;)

> You probably want to avoid recursion in this case:
>
> void wait()
> {
>     char[] a;
>     while(a != "A")
>     {
>         writeln("Type A to continue!");
>         stdin.readln(a);
>     }
> }
>
> -Steve

I want the two examples to generate comparable code.


More information about the Digitalmars-d-learn mailing list