GCC let's you do closures with C

By 8 nic on March 13, 2007

Nested functions allow closure. I once wrote a Scheme interpreter using this trick of the compiler. It was very fast.

Embed Claim Make a related claim

Discussion (7)

http://bcat.myopenid.com/

10 Jonathan Rascher who agreed, says

Now this is interesting. Thanks for the heads-up!

Make a related claim about 1 year ago (link)
http://vynce.myopenid.com/

8 Vynce who hasn't voted, says

please tag "computer, programming"

Make a related claim about 1 year ago (link)
http://darch.myopenid.com/

6 D'Archangel who agreed, says

That is so awesome, it is retarded.

D'A

Make a related claim about 1 year ago (link)
http://www.tapsellferrier.co.uk/nicferrier/

8 nic who agreed, says

It's not retarded... lexical closure is so simple to do in any language with enforced declarations that it's a wonder it's not MORE common place. Ada does not support closure for example, but it could.

Make a related claim about 1 year ago (link)
http://darch.myopenid.com/

6 D'Archangel who agreed, says

You misunderstand. I'd run straight out of superlatives and had to start on the other side to express the degree to which this gladdens my sick and twisted heart.

D'A

http://chronos-tachyon.net/

4 Chronos Tachyon who agreed, says

Poor, poor GCC. Closures without garbage collection look quite painful.

Of course, I am speaking of the language that has stack-based continuations (longjmp).

Make a related claim about 1 year ago (link)
http://www.tapsellferrier.co.uk/nicferrier/

8 nic who agreed, says

C does too have collection (on automatic variables).

Note: I didn't say garbage collection!!

When the function ends the automatic's are collected. Doing closures is no worse than any other function as far as I can see - it's still a giant pain in the bum.

Make a related claim about 1 year ago (link)
Sign in in to leave a comment.