Thanks for this Corey,
If I ever go completely bonkers and choose to program in C++, I'm sure
that this code snippet will help.
I am not being sarcastic.
----- Original Message -----
From: "Corey Murtagh" <[EMAIL PROTECTED]>
To: "Trevor Jones" <[EMAIL PROTECTED]>; "NZ Borland Developers Group -
Delphi List" <[EMAIL PROTECTED]>
Sent: Saturday, March 20, 2004 8:52 PM
Subject: Re: [DUG] [OT] Multiple "FOR" loops
> Trevor Jones wrote:
>
> > Jeremy,
> > unless I am very badly mistaken, this looks like a job for a language
> > feature which AFAIK only exists in Pascal: nested procedures/functions.
>
> Pascal doesn't have a monopoly on nested procedures. For example,
> although not directly supported in C++, you can fake nested functions
> using structures and the execute operator:
>
> void DoStuff(TUpDown Dircetion, int Lower, int Upper)
> {
> struct {
> void operator()(int x)
> {
> // do stuff here...
> }
> } ReallyDoStuff;
>
> if (Direction == Up)
> for (int x = Lower; x <= Upper; ++x)
> ReallyDoStuff(x);
> else
> for (int x = Uppwer; x >= Lower; --x)
> ReallyDoStuff(x);
> }
>
> --
> Corey Murtagh
> The Electric Monk
> "Quidquid latine dictum sit, altum viditur!"
> _______________________________________________
> Delphi mailing list
> [EMAIL PROTECTED]
> http://ns3.123.co.nz/mailman/listinfo/delphi
>
>
_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi