Tue, 20 Oct 2009
When teaching, the questions from the audience provide an important feedback to me - a notion of whether I was successful in passing the information to the audience, and what to improve or explain in a different way. There are, however, rare occasions when the question just makes me think "WTF?".
Yesterday I tried to explain the
semantics. These two functions are not straightforward, and it probably
takes a while to wrap one's mind around them.
But after that, the usage is quite simple:
the target of the non-local jump is firstly initialized using
setjmp(3), and later the jump itself can be made using
longjmp(3). I have written the following code snipplet
to demonstrate it:
During the lecture when I asked whether there were any questions, the question
was: "But is there any framework for those functions?".
I was totally puzzled:
I probably don't know all the meanings of the English word "framework",
but I think it means something like a higher-level abstraction or environment
to wrap the lower-level things in order to make them simpler to use (often at
a cost of freedom of how to do things). But can this fancy
be made even simpler than it is? It would still be necessary to declare
the label somehow (
setjmp(3)) and then jump to it
WTF? What framework?
5 replies for this story:
Hynek (Pichi) Vychodil wrote: framework
'framework' is just magic word. When you hear 'framework' you should hear 'abrakadabra'. 'abrakadabra' will solve our problems with performance. Bullshit, it is anopther layer which must make worse performance. 'abrakadabra' will improve our productivity. Bullshit, people would learn it first and then can be more productive if ever. You will usually must cope with framework bugs and restraints. 'abrakadabra' will solve our problems with scalability. Bullshit if there is not scalability involved in your solution yet and framework have to support it. Framework is cargo cult or incantation for people which would not like think.
Milan Zamazal wrote:
I guess the construct looks just unnatural today, when most programming languages in common use provide exception handling. For first, people aren't accustomed to meet and use goto constructs. For second, there is usually no need to make exception handling explicit ("if (fatal_error) ..."). For third, error handlers are typically declared in more elegant ways, e.g. `trap' (shell) looks more natural than the setjmp call. So a person who haven't been exposed to roots of our generation (BASIC, C, assembler) can't match your example to his standard patterns and may think there *must* be a less ugly way to do it. Is it the first time you have felt like the young generation can't understand you? ;-)
Yenya wrote: Re: Milan Zamazal
I have been thinking along the lines of "Java generation can't understand me" rather than "young generation can't understand me" :-)
If you are teaching on the school where Assembly language is a bad word and for every C oriented course there is a dozen of Java oriented, what do you expect?
What they probably want is: #define DECLARE_LABEL(x) jmpbuf x #define DEFINE_LABEL(x) if (setjmp(x) != 0) #define JUMPTO_LABEL(x) longjmp(x, errno) Which would make the code more obfuscated as is the desire of the true framework programmers. :)