setjmp/lonjmp (was: vinum warning)

Greg 'groggy' Lehey grog at lemis.com
Tue Feb 15 15:45:02 PST 2005


On Thursday,  3 February 2005 at 16:23:38 -0800, Matthew Dillon wrote:
>
>>>      I'm going to nit on this.
>>>
>>>      Using longjmp is evil.  Period.
>>
>> Is that the only justification you have for your opinion?
>
>     The problem, Greg, is that when you use something like that in a
>     large project you basically remove a large number of programmers
>     from the set of programmers able to work, maintain, and extend
>     your code.

That's a secondary issue.  Not that I disagree, but my question was
related to the construct only.  What you say below is interesting, but
not what I was talking about.

>     Your code is especially difficult to maintain.  I'm not saying
>     its bad, just that it's especially difficult for people other
>     then yourself to wrap their hands around and actually work with
>     because of the lack of in-code documentation, weird code
>     constructions that nobody else uses, weird indentation that
>     doesn't seem to work with anyone else's editor, the extremely
>     deeply nested statements you have, lack of compartmentalization
>     of major function sets, and other things.  I've tried to do
>     cleanups of your vinum code before and, believe me, it is a
>     frustrating experience!

Sorry to hear about it.  Yes, I agree, I don't exactly adhere to
style(9).  That's because I consider style(9) to be outdated.  But
it's clear that it doesn't make my code any easier to read for those
people who are used to style(9).

>     Now, so you don't feel bad, Kirk's code comes in a close second.

Heh.  I don't feel bad :-)  But thanks, anyway.

>     It's probably a generational thing.  One of the reasons why I am
>     allowing people to do major cleanups of our code base is
>     precisely to try to make the code more maintainable and more
>     comfortable for more recent generations of programmers.

Paradoxically (as I said above), I think the current code style is
older.  To get back to the topic, I think that setjmp/longjmp is a
more modern construct.  Admittedly it's (marginally) more difficult to
understand setjmp/longjmp than it is to understand a chain of function
returns, and there's additional potential to break something, but I
don't see either of these as serious, and I do see the advantages as
significant, particularly in the untidy area of checking return codes
at every step.  You obviously don't, and I was asking about your
reasons.

Greg
--
When replying to this message, please copy the original recipients.
For more information, see http://www.lemis.com/questions.html
Finger grog at xxxxxxxxx for PGP public key.
See complete headers for address and phone numbers.
Attachment:
pgp00017.pgp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00017.pgp
Type: application/octet-stream
Size: 187 bytes
Desc: "Description: PGP signature"
URL: <http://lists.dragonflybsd.org/pipermail/kernel/attachments/20050215/a5a4fe94/attachment-0016.obj>


More information about the Kernel mailing list