Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

What is the Purpose of Closures?

Name: Anonymous 2012-02-29 8:48

I really don't understand what the purpose of closures is. It seems to me that everything that can be written using closures, is just as easily written without. For example:


void main()
{
    int[] haystack = [345,15,457,9,56,123,456];
    int   needle = 123;
    bool needleTest(int n)
    {
        return n == needle;
    }
    printf(find(haystack, &needleTest));
}


Wouldn't this be better written as:


void main()
{
    int[] haystack = [345,15,457,9,56,123,456];
    int   needle = 123;
    foreach(int i : haystack)
    {
        if (i == needle)
        {
            printf(i);
        }
    }
}


Or at least defining the function outside of main() and referencing it inside? I just don't understand the benefit of closures.

Name: Anonymous 2012-03-02 12:30

>>27
UuUUUu uUuuUUu U UUuuUUu!!!??! U u Uuu?!!!?!! uuuu uUUUu UUuu UUuu uuUu uuuu u U??!??!! uUu U!!!!?!! U uu?!???!! U!????!! Uuuuuu uuUUUUu uuuuuu uUUuuu U??!!?! uuuuuu uUUUUUu UUuUUUu uUUUUUu UUUUUUu U?!!!?! UuUUUu uUuuUUu U UUuuUUu!!!??! U uUuu!????!! Uu uuUu U UUuu u Uu u!!???!! uuuuuu uuuUuu uUuUUUu uUuUUUu uuUUuu uUUuuu uuuUuu U?!!!?! U!??!??! UUuu uuUu uuuu UUUUu u U??!??!! uuuu uu U!?!??!! UUUUu UUuu UuUUu uuuu U Uu!!???!! U uUUu UUuu?!!??!! U uUuu!????!! UuuUuu uuuuuu UUuUuu UUUUUUu uUuUuu UuuUuu uuUUUUu U uUuUuu UuuUuu UUuUuu UUUUUUu uUuUuu UuuUuu uuUUUUu!!!!?! UUuu U u uuUu???!?!! uUUUUUu uuUUUUu UuuUUUu UuUUUUu uUuuuu UuUUUUu uuUuuu U??!!?! uu U?!!??!! UuUu U Uuu!!!!?!! uUuUuu uuUUuu UUuUUUu uuuUuu U?!!!?! U uUUUUu UuuUUu?!!!??! uuUUu uuu U uuUUu!????!! UuUu U Uuu!!!!?!! Uu U uUuu!????!! U uUUUu U uUUu!?!??!! uUUUu UUu U uu!????!! UuuUUUu UuUuuu uuUuuu uUuUUUu U?!!!?! tomot

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List