|
Manslaughter posted:I've been given an assignment to create an XSL that will insert the appropriate RTF tags to format XML to a client's liking. Did you have a discussion with the source of the request to see why they want/need that? 90% of the time when a totally nonsensical request comes through, it's because no one understands what they actually want or need.
|
# ? Feb 3, 2014 22:40 |
|
|
# ? May 17, 2024 16:19 |
|
Plorkyeran posted:Might as well save some time and annoyance and just kill yourself now. The note better be well-formed or the attempt will probably just error out.
|
# ? Feb 3, 2014 22:50 |
Ithaqua posted:Did you have a discussion with the source of the request to see why they want/need that? 90% of the time when a totally nonsensical request comes through, it's because no one understands what they actually want or need. Client needs: Docs that are formatted to their preferences Our needs: Money, and a new system that supports something other than RTF (yeah right) TBH this client has no idea what they want. They'll request customization, get billed for it, then request that exact same customization be removed (and you better believe they get billed the same amount for removal).
|
|
# ? Feb 3, 2014 23:13 |
|
Manslaughter posted:I've been given an assignment to create an XSL that will insert the appropriate RTF tags to format XML to a client's liking. At first I read that as "XLS", and thought they wanted Excel macros. So, look on the bright side...
|
# ? Feb 3, 2014 23:52 |
|
Suspicious Dish posted:At first I read that as "XLS", and thought they wanted Excel macros. So, look on the bright side... I'm not sure that'd be worse. If you have access to Word's stuff from excel macros then it'd actually be easier to create a RTF file from there than via XSLT.
|
# ? Feb 3, 2014 23:56 |
|
Steve French posted:If you're going to build a shed with pointers, That is indeed an appropriate contribution for this thread, since it has undefined behavior on one of its inputs.
|
# ? Feb 4, 2014 00:10 |
|
Jewel posted:I was confused about why "warning = limit * persentage" wouldn't work. I haven't worked with C++ in a little while so I thought "hm, does 'limit * persentage' create a new unsigned char of the multiplication, then cast that to long? I thought that makes sense so I did a quick test to see what the output would be. I got: C++ code:
I keep "persentage" around to remind me how much I hate cleaning up other people's messes. It's a great source of rage when I have to poke around the spaghetti pile for whatever minor misfeature I need to add. Except I don't anymore, since it's all rebuilt on a new chip so oh well that PIC-specific code just gosh darn didn't port and I had to re-implement.
|
# ? Feb 4, 2014 00:45 |
|
Scaevolus posted:Fizzshedding: dozens of replies arguing about implementations of a trivial interview question. This happens every time someone posts about interview questions. Some of you nerds just can't help making it into an e-penis contest instead of focusing on, you know, the actual discussion. Hey everyone, look at meeeeeeeeee!
|
# ? Feb 4, 2014 03:46 |
|
Many programmers lack the self-awareness necessary to understand when writing code is not the solution, and the code they write winds up in this thread.
|
# ? Feb 4, 2014 07:49 |
|
Smugdog Millionaire posted:Many programmers lack the self-awareness necessary to understand when writing code is not the solution, and the code they write winds up in this thread. Really, we're just being efficient.
|
# ? Feb 4, 2014 08:40 |
|
Ender.uNF posted:This happens every time someone posts about interview questions. Some of you nerds just can't help making it into an e-penis contest instead of focusing on, you know, the actual discussion. Hey everyone, look at meeeeeeeeee! The discussion is whatever we make the discussion.
|
# ? Feb 4, 2014 09:17 |
|
Ender.uNF posted:This happens every time someone posts about interview questions. Some of you nerds just can't help making it into an e-penis contest instead of focusing on, you know, the actual discussion. Hey everyone, look at meeeeeeeeee! Wait, so are you participating in the actual discussion?? Here I thought it was reasonable to talk about code. I helped start the "derail" by asking some pointed questions intended to highlight the possibility that someone had misunderstood why their interview performance was perceived as poor. THEN I put forth my entry in the e-penis contest because guess what? I actually enjoy thinking of and implementing various solutions to these sorts of problems. AND I ended up learning something from it. From shrughes, who you all seem to hate for some reason or another. Maybe be less upset about things I guess?
|
# ? Feb 4, 2014 17:50 |
|
shrughes posted:That is indeed an appropriate contribution for this thread, since it has undefined behavior on one of its inputs. Out of curiosity what's the UB?
|
# ? Feb 4, 2014 18:16 |
|
return0 posted:Out of curiosity what's the UB? I've written all of ~ten lines of C in my life, but undefined behaviour is usually at the boundaries. In this case, set len = 0. Then e = s - 1, and (if I'm remembering rightly) since pointers to arrays are pointers to their first element, e is a pointer to one before the first element, which is an invalid pointer.
|
# ? Feb 4, 2014 18:23 |
|
Obviously it just requires that you start your strings at the second byte of the allocation.
|
# ? Feb 4, 2014 18:33 |
|
Isn't that a moot point anyway? At len=0, the while loop ends up as (s < s-1), which immediately fails and the function returns 1. You're never dereferencing the pointer that way.
|
# ? Feb 4, 2014 19:20 |
|
code:
|
# ? Feb 4, 2014 19:23 |
|
Admiral H. Curtiss posted:Isn't that a moot point anyway? At len=0, the while loop ends up as (s < s-1), which immediately fails and the function returns 1. You're never dereferencing the pointer that way.
|
# ? Feb 4, 2014 19:27 |
|
Gazpacho posted:I was a bit surprised, but I checked the C99 draft and it says that only address calculations within an array and just past the end are defined. An address just before the beginning is right out, regardless of whether you dereference it. There aren't any arrays in that code...?
|
# ? Feb 4, 2014 19:30 |
|
Generally speaking, if the pointer isn't pointing into an array then you've done something undefined before you call the function.
|
# ? Feb 4, 2014 19:32 |
|
qntm posted:There aren't any arrays in that code...? coffeetable fucked around with this message at 20:07 on Feb 4, 2014 |
# ? Feb 4, 2014 20:04 |
|
The reason I thought "Oh, a higher level language - I'll split and flip one half then compare!" was because I had just come from C. Welp.
|
# ? Feb 4, 2014 20:25 |
|
qntm posted:There aren't any arrays in that code...?
|
# ? Feb 4, 2014 22:05 |
|
edit: wrong thread
Fuck them fucked around with this message at 22:33 on Feb 4, 2014 |
# ? Feb 4, 2014 22:29 |
|
Admiral H. Curtiss posted:Isn't that a moot point anyway? At len=0, the while loop ends up as (s < s-1), which immediately fails and the function returns 1. You're never dereferencing the pointer that way. On a somewhat plausible architecture, s could underflow resulting in an incorrect result from the comparison. On other architectures, if the compiler inlined the function, the compiler could hypothetically assume that len > 0 based on the code it sees (because undefined behavior) and generate assembly code that doesn't do the right comparison the first time it enters the loop.
|
# ? Feb 4, 2014 23:23 |
|
That actually sounds pretty interesting - which compilers do that? I'm self-studying optimisation at the moment so that'd be a good thing to look at.
|
# ? Feb 4, 2014 23:44 |
|
I'm not naming a specific optimization that a compiler might do or any compiler behavior I specifically know about. This is just a hypothetical code generation decision (which seems pretty unlikely). You could imagine it generating some assembly that for whatever reason looks something like this: code:
You can see other circumstances where undefined behavior results in a surprise optimization, like seen http://lwn.net/Articles/342330/ <- there.
|
# ? Feb 5, 2014 00:16 |
|
shrughes posted:You can see other circumstances where undefined behavior results in a surprise optimization, like seen http://lwn.net/Articles/342330/ <- there. This is pretty cool tbh
|
# ? Feb 5, 2014 01:07 |
|
Steve French posted:Wait, so are you participating in the actual discussion?? Here I thought it was reasonable to talk about code.
|
# ? Feb 5, 2014 01:20 |
|
shrughes posted:where it decides without any particular optimization in mind that it would like to use a jump-if-zero instruction instead of jump-if-not-less-than because it "knows" len is not 0. And where it has comparisons at both ends of the loop (which happens sometimes). Interesting - thanks for the clarification. It's a good example of a compiler not following its supposed principles (i.e. not changing semantics) due to ambiguous syntax. Good eye!
|
# ? Feb 5, 2014 01:28 |
|
Steve French posted:AND I ended up learning something from it. From shrughes, who you all seem to hate for some reason or another.
|
# ? Feb 5, 2014 01:29 |
|
Yeah I mean I disagree with shrughes on most social points but he knows his C (family).
|
# ? Feb 5, 2014 01:31 |
|
2banks1swap.avi posted:The reason I thought "Oh, a higher level language - I'll split and flip one half then compare!" was because I had just come from C. Why?
|
# ? Feb 5, 2014 01:32 |
|
Tesseraction posted:Yeah I mean I disagree with shrughes on most social points I doubt this is true. I only argue with irrational arguments people here make because they're irrational, not because the end conclusion is right or wrong.
|
# ? Feb 5, 2014 01:34 |
|
shrughes posted:I doubt this is true. I only argue with irrational arguments people here make because they're irrational, not because the end conclusion is right or wrong. I will willingly and happily argue this, hoping to be wrong, but not in this thread.
|
# ? Feb 5, 2014 01:38 |
|
|
# ? Feb 5, 2014 01:49 |
|
Tesseraction posted:Interesting - thanks for the clarification. It's a good example of a compiler not following its supposed principles (i.e. not changing semantics) due to ambiguous syntax. Good eye! I think you still might not fully understand what undefined behavior is all about.
|
# ? Feb 5, 2014 02:00 |
|
No, I'm pretty sure I do. Sorry my post produced undefined behaviour in your interpretation?
|
# ? Feb 5, 2014 02:34 |
|
Tesseraction posted:No, I'm pretty sure I do. Sorry my post produced undefined behaviour in your interpretation? You said the compiler changed semantics when in fact it didn't.
|
# ? Feb 5, 2014 02:55 |
|
|
# ? May 17, 2024 16:19 |
|
FamDav posted:Why?
|
# ? Feb 5, 2014 02:57 |