LWN.net Logo

GNU sed 4.2.2 released; maintainer resigns

GNU sed 4.2.2 released; maintainer resigns

Posted Dec 23, 2012 23:27 UTC (Sun) by daglwn (subscriber, #65432)
In reply to: GNU sed 4.2.2 released; maintainer resigns by lu_zero
Parent article: GNU sed 4.2.2 released; maintainer resigns

You cannot do RAII in C. End of story.


(Log in to post comments)

GNU sed 4.2.2 released; maintainer resigns

Posted Dec 23, 2012 23:36 UTC (Sun) by walters (subscriber, #7396) [Link]

GNU sed 4.2.2 released; maintainer resigns

Posted Dec 24, 2012 8:15 UTC (Mon) by khim (subscriber, #9252) [Link]

If you have GCC then you have C++, too. The lu_zero's fit of hysteria is related to the fact that you may have only some other, quite limited and deficient compiler instead. Which probably means that not only GCC extensions are not permittable but that ANSI C is "too new" and K&R C should be supported forever.

I think that since it's exclusively his problem (most other guys do a bootstrap using some other platform with full-blown GCC nowadays not a vendor-provided compiler) he can support any compiler he wants in said state, but it's not a good enough reason to make life for everyone else miserable.

GNU sed 4.2.2 released; maintainer resigns

Posted Dec 26, 2012 12:06 UTC (Wed) by lu_zero (guest, #72556) [Link]

Would be _nice_ to stick to the standards and have standards improve.

The great thing about gcc is/was the fact you can get a good compiler to replace the shoddy one you had or that is just there.

GNU sed 4.2.2 released; maintainer resigns

Posted Dec 26, 2012 20:02 UTC (Wed) by daglwn (subscriber, #65432) [Link]

1. That is not C.

2. That does not cover all cases.

One must have proper exception handling as well as destructor-like routines.

talloc as an RAII alternatives in C

Posted Dec 24, 2012 8:35 UTC (Mon) by scottt (subscriber, #5028) [Link]

> You cannot do RAII in C. End of story.
Apache and Samba manage resource handles through apr_pool_t and talloc and they fair pretty well despite being written in C.

talloc as an RAII alternatives in C

Posted Dec 24, 2012 19:56 UTC (Mon) by Cyberax (✭ supporter ✭, #52523) [Link]

Nope. They don't have RAII, they have refcounted pools. It's about the best you can do in plain C.

GNU sed 4.2.2 released; maintainer resigns

Posted Dec 24, 2012 22:31 UTC (Mon) by paulj (subscriber, #341) [Link]

You can do RAII in C, you just need explicit scaffolding to setup the context that will destroy the objects. E.g. you can lift the destruction out of the code doing the work, by using a wrapping function that holds the state and cleans up after the "work" function - explicitly doing something equivalent to what a C++ compiler would do.

We've been in a thread on this before, which was also interesting: http://lwn.net/Articles/424527/

If you define RAII as requiring destruction to be tied into the scope in the language, then yes C doesn't have it. If you mean something more abstract, then you can implement it in C just fine. You have to implement it yourself then, of course, rather than let the C++ compiler do the work, but it's still possible, AFAICT. Surely?

GNU sed 4.2.2 released; maintainer resigns

Posted Dec 25, 2012 0:18 UTC (Tue) by Cyberax (✭ supporter ✭, #52523) [Link]

Well, yeah. You can do pretty much anything in C (except non-sjlj exceptions which require true compiler support), but you have to do it manually.

And that's the point - doing things manually is error-prone and code-bloating.

GNU sed 4.2.2 released; maintainer resigns

Posted Dec 25, 2012 12:47 UTC (Tue) by paulj (subscriber, #341) [Link]

Having to create your own infrastructure - doing it manually - doesn't of course mean you have to do it manually from scratch at every point. You can re-use your infrastructure of course. It will take a little more typing than "}" though, sure. That needn't mean it's more error-prone though, imho.

GNU sed 4.2.2 released; maintainer resigns

Posted Dec 25, 2012 21:35 UTC (Tue) by Cyberax (✭ supporter ✭, #52523) [Link]

Everything that is not automatic is error-prone. Especially in rarely-tested code paths.

GNU sed 4.2.2 released; maintainer resigns

Posted Dec 26, 2012 20:17 UTC (Wed) by lu_zero (guest, #72556) [Link]

Everything is error prone then.

One of the issues I do have with C++ is that you must use a really strict subset (defeating the whole purpose of having such large standard library) in order to be reasonably sure your code will build and behave as you expect across different compiler/libstdc++ implementations.

And that because C++ is so complex and hard to implement that you have lots of interesting pitfalls.

GNU sed 4.2.2 released; maintainer resigns

Posted Dec 26, 2012 20:25 UTC (Wed) by Cyberax (✭ supporter ✭, #52523) [Link]

Not everything, only the stuff that humans do directly.

> One of the issues I do have with C++ is that you must use a really strict subset
The only reason is to avoid incomprehensibly complex code.

> (defeating the whole purpose of having such large standard library) in order to be reasonably sure your code will build and behave as you expect across different compiler/libstdc++ implementations.
That hasn't been true for ages. All modern STL implementations are reasonably compatible - you won't find problems with standard containers and algorithms.

GNU sed 4.2.2 released; maintainer resigns

Posted Dec 27, 2012 16:53 UTC (Thu) by bronson (subscriber, #4806) [Link]

> ... you must use a really strict subset in order to be reasonably sure your code will build and behave as you expect across different compiler/libstdc++ implementations.

To be fair, this is true of libc too. "Always use glibc" dodges the problem (and not very successfully since glibc has so many obscure, dark corners).

GNU sed 4.2.2 released; maintainer resigns

Posted Dec 26, 2012 20:03 UTC (Wed) by daglwn (subscriber, #65432) [Link]

> If you define RAII as requiring destruction to be tied into the scope in
> the language, then yes C doesn't have it.

Well of course that's what I mean! That is the whole point.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds