Slashdot Mirror


User: pthisis

pthisis's activity in the archive.

Stories
0
Comments
1,665
First seen
Last seen
Profile
(view on slashdot.org)

Comments · 1,665

  1. Re:null pointer on Bjarne Stroustrups and More Problems With Programming · · Score: 1
    So here you are: 0 is the null pointer constant. Please note the lower caps null - NULL is just a define:

    Good catch on the caps.

    A null pointer constant is _not_ the same as the representation of a null pointer (the "null pointer value"). A null pointer constant can be used to set or compare a null pointer only in pointer contexts.

    I'll note briefly before going into more detail that the most common mistake caused by assuming that the null pointer value is 0 is to assume that:

    struct foo {
      void *next;
    };
    ...
    struct foo * my_foo = calloc(sizeof *my_foo, 1);
    has a null pointer as my_foo->next. It will on common platforms, but it is not required in a conforming implementation. I'm pretty sure that a null member of a static struct likewise doesn't have to be initialized to a null value, but I'd have to double-check that.

    As for using memcpy: how actually are you going to memcpy a 0 or NULL? They both don't have an address to copy from.

    In more detail, what I mean is that this:

    intptr_t some_int = 0;
    void * some_ptr;
     
    memcpy(&some_ptr, &some_int, sizeof(some_ptr));
    or this:

    memset(&some_ptr, 0, sizeof(some_ptr));
    Or even this*:

    some_ptr = (void *)some_int /* some_int is 0, but not a 0 constant */
    is not guaranteed to give you a null pointer in some_ptr. After any of those three, then any of the following lines:

    if(some_ptr) print("Pointer isn't null!\n);
    if(some_ptr != NULL) print("Pointer isn't null!\n);
    if(some_ptr != 0) print("Pointer isn't null!\n);
    is free to print "Pointer isn't null\n" in a conforming implementation. But if you had instead done "some_ptr=0;", "some_ptr = 3/4;", "some_ptr = NULL;" or similar (using NULL, a constant 0, or the constant 0 cast to the appropriate pointer type) then a conforming implementation would have to set the value of some_ptr to the null pointer value, and those if branches would not be taken.

    So to re-phrase my statement:

    Saying "the null pointer is zero" is wrong. A conforming implementation can have a representation of the null pointer that is not all-bits-zero. The NULL constant and/or a 0 constant can be used in pointer contexts to set and compare the null value of a pointer, but when you say "some_ptr = 0" there could be a lot of magic going on to set the actual value of the bits in some_ptr. In non-pointer contexts there's nothing guaranteeing a null pointer has a zero value, or that setting a pointer to a zero value will result in a null pointer. Even in pointer contexts, there's no guarantee that using a non-constant zero will result in a null pointer*.


    The bad news is: int might not be large enough to hold a pointer (It's defined in 6.3.2.3 as well) and indded is not for x86_64. One is supposed to use intptr_t or uintptr_t.


    The worse news is that intptr_t and uintptr_t need not be defined, specifically because on some machines there is no integer type large enough to hold a pointer. You cannot portably assume they exist. You _can_ portably treat a void pointer as a sequence of characters, which is generally the best approach if you need to play pointer games (though usually that's a bad idea).

    As long as we're on the pointer subject, it's also worth noting that you can't portably assume a void pointer is large enough to hold all pointer types (it'll portably hold object pointer types but not function pointer types).

    The latter relates back to the topic, because on some platforms function pointers have different representations than non-function pointers, and on some of those function pointers are the only type of pointer that has non-zero representation of the null pointer.

    *There's some argument about whether an unrelated change in C99 might force this to set a pointer to the null value, but I'm unsure as to what the current consensus is. Certainly the other cases remain unchanged.
  2. Re:"Also, the first Web browsers." on Bjarne Stroustrups and More Problems With Programming · · Score: 1

    Sure, but that doesn't change the fact that the Mosaic source code is not C++, it's C. Looking at it for even a second shows at least a few places that don't cast the return value of malloc or otherwise are legal C but illegal C++.

    (and no, C is not a subset of C++)

  3. Re:Only it's not C++ on Bjarne Stroustrups and More Problems With Programming · · Score: 1

    The C++ (as well as C99) standart defines 0 to be the NULL pointer

    Not strictly true. See the comp.lang.c FAQ for details. 0 in pointer contexts is recognized as the NULL pointer by the compiler, but that's not equivalent to defining 0 to be the NULL pointer.

    It's true that

    my_pointer = 0;

    will set my_pointer to the NULL pointer, and that things like "if(my_pointer==0)" are safe.

    But e.g. trying to memcpy 0 into a pointer is not guaranteed to give you a NULL pointer, while memcpy of a NULL pointer into another pointer will make the second pointer NULL.

  4. Re:Great! on Top Gadget of 2006 — The HurriQuake Nail · · Score: 1

    A typical wood house will stand for well over 100 years (we have several in my home town--Brunswick, ME--that are well over 250 years old). It will also be cheaper to build and require much less maintenance than a brick or concrete house. Historically they've also been more efficient to heat/cool and easier to wire, and the building process is less environmentally damaging unless you use old-growth hardwood (which is expensive and uncommon). They're also much less susceptible to environmental damage from repeated freezing/thawing.

  5. Re:WhoTF? on UK Copyright Extension Not Happening · · Score: 2, Interesting

    Jethro Tull is somewhat well known 60s band

    They started in the 60s, but had their biggest hits in the 1970s and a Grammy for best hard rock/heavy metal album in the mid/late 1980s (I'd guess 1987). Grammys are certainly no measure of talent, but by both critical acclaim and album sales they're more of a 1970s prog rock/1980s hard rock band than a 60s band.

    Also, "somewhat" well known might be a bit of an understatement; having more than one #1 album in the USA (more in the UK) puts you pretty solidly in the well-known category compared to even successful rock outfits. They're certainly not the Beatles, Zeppelin, Pink Floyd, or the Stones; they're not quite the Who or the Eagles, but not knowing them is pretty solidly in the "ignorant of 1970s/80s rock" camp. (And I don't endorse the music of the bands I mentioned, I merely mention them as measures of popularity).

  6. Re:Damages for companies? on Judge OKs Challenge To RIAA's $750-Per-Song Claim · · Score: 1

    Yes, $750/work is the minimum statutory damages as I said. Plaintiff can always opt for real damages in lieu of statutory damages, but in most civil cases it's rarely worth either the plaintiff or defendant's time to do that for smallish claims--that it _would_ be worth defendant's time (not that they have the option) in this case is a sign that the statutory damages are out of whack.

  7. Re:Damages for companies? on Judge OKs Challenge To RIAA's $750-Per-Song Claim · · Score: 1

    Yes, but AFAIK that's not at issue in this case yet; this challenge is simply to the reasonableness of the law itself. I'm not sure whether it's an open-and-shut "the defendant obviously did it" kind of case where the only thing they're challenging is the amount of the award, or if it's a more open-ended case and this is only one part of the defense.

  8. Re:Damages for companies? on Judge OKs Challenge To RIAA's $750-Per-Song Claim · · Score: 1

    High end: If Steven Kings books get copied and sold to all of China, the damage could easily be worth far more than 30k.

    The copyright holder always has the option of recovering actual damages instead of statutory damages, and in the case of the Steven King example they'd probably opt for that. Statutory damages are intended for cases where going out and determining exactly how many copies were made and what the market value of each was is infeasible or not worth the time of the plaintiff and defendant.

    But yes, the statutory amount seems high here. Perhaps a low of $750 for all copyright violations stemming from one linked set of actions might be reasonable (so if someone puts up 400 albums to share, the RIAA can either go with $750 total or figure out real damages, rather than being allowed to go for 400 * $750 = $300000 without justification). Note that statutory damages are often intentionally somewhat higher than real damages, as they have punitive effects in addition to simply correcting the damages done; while $750 is a high amount for most file sharer's real impact on sales, it's not completely out of the realm of reasonable as a punitive figure (the law, of course, already operates under the assumption that file sharing is wrong and should be punished).

    For more info (statutory amounts are in (c)(1)) see:
    http://frwebgate3.access.gpo.gov/cgi-bin/waisgate. cgi?WAISdocID=19805814327+0+0+0&WAISaction=retriev e

  9. Re:RIAA defense... on Judge OKs Challenge To RIAA's $750-Per-Song Claim · · Score: 1

    Their argument is likely to be that she _can_ be held responsible for people who downloaded the song from her computer, because then she's distributing it herself. What's interesting about this is, if she proves that song downloads are only worth .70 cents, the RIAA will have to prove that 1000 people downloaded the song from here to get their $700/song, and they'll have to do that for each song.

    They won't have to prove any such thing. The $750/work is specified by law as the minimum statutory damages for copyright infringement, it's not a number that the RIAA came up with or needs to justify. The argument is about whether the law is an unreasonable violation of due process; the RIAA aren't the ones who picked the figure.

    See (c)(1):
    http://frwebgate3.access.gpo.gov/cgi-bin/waisgate. cgi?WAISdocID=19805814327+0+0+0&WAISaction=retriev e

  10. Re:Linear vs. Exponential Spread Responsibility on Judge OKs Challenge To RIAA's $750-Per-Song Claim · · Score: 1

    The RIAA is indirectly arguing (through its high damage calculations) that if you upload a file, then you are responsible for its exponential growth in sharing

    The RIAA is not doing any damage calculations. The law specifies $750 as the minimum statutory damage. See (c)(1) at http://frwebgate3.access.gpo.gov/cgi-bin/waisgate. cgi?WAISdocID=19805814327+0+0+0&WAISaction=retriev e

  11. Re:Damages for companies? on Judge OKs Challenge To RIAA's $750-Per-Song Claim · · Score: 1

    Well, at first blush, the disparity between cost and damages is enourmous. It doesn't really seem reasonable. But the RIAA bases such things on the premise that if I download a copy of a song, I will only ever have the one copy. Their whole focus is to ensure somehow that I get one copy and only one copy for my money, and that I cannot simply crank out a thousand or more copies for myself, even if my intent is benign. They don't seem to understand that as technology has advanced, their ability to control content has slipped slowly away. DRM is the last shriek of the dying -- trying to control the content even when it is out of their control.

    So they see $750 as a justifiable figure


    They may or may not, but the case isn't about what the RIAA thinks. $750 is specified by law as the minimum statutory per-work damage. See 17USC504 (c)(1) at:

    http://frwebgate3.access.gpo.gov/cgi-bin/waisgate. cgi?WAISdocID=19805814327+0+0+0&WAISaction=retriev e

    The challenge isn't to a random RIAA-picked number, it's to the law itself for specifying an arguably unreasonable amount in statutory damages.

  12. Re:Damages for companies? on Judge OKs Challenge To RIAA's $750-Per-Song Claim · · Score: 1

    If I was a judge and could rule however I want, I'd calculate is as the number downloads estimated to come from the file sharer in question, minus the percentage of downloads that actually count as a loss of sales to the studios.

    Actually, the law sets statutory amounts for how much a violation is worth that the courts are bound by.

    In this case, the law specifies that unless you can figure out the actual damages, the damages have to be between $750 and $30,000 per work infringed--no other estimation is allowed. The RIAA weren't the ones who picked the $750 number, that's simply what the law specifies.

    The argument here isn't that the RIAA picked some random high number without justification, it's that the law's minimum damages are so unreasonable as to be an unconstitutional violation of due process.

  13. Re:Damages for companies? on Judge OKs Challenge To RIAA's $750-Per-Song Claim · · Score: 3, Insightful

    what I'm curious about is who checks that the RIAA hasn't already put a claim in for this particular song somewhere further up the chain? ie. person A shares a file that persons B,C & D download. RIAA files a suit against person A, claims $750 damages. Person A pays. RIAA now files suits against B,C & D (who are now also sharing the file) claiming $750 from each of them too, even though, in theory the claim against person A was for ALL downstream sharing too.

    The original claim was not for all downstream sharing. It was simply the minimum statutory damage specified by Congress when they wrote the law.

    The issue here is not that the RIAA picked an unreasonable figure; the $750 is actually the _minimum_ statutory amount they can ask for. The issue is that the statutory amounts are arguably so unreasonable as to be an unconstitutional violation of due process.

    The defendant is not challenging the RIAA per se, but rather the constitutionality of the law itself.

  14. Re:Damages for companies? on Judge OKs Challenge To RIAA's $750-Per-Song Claim · · Score: 1
    I am not a lawyer; this is my personal understanding, not legal advice.

    However, if the number of copies distributed illegally cannot be determined, there is no way to compute damages, right?


    Right. That's the whole reason that there are statutory damages.

    What if I sue you for "numerous incidents of toe-stepping, leading to loss of income in an undetermined amount due to inability to work brought about by physical and emotional damage suffered as a result of said incidents" and demand $1000k? Should you be forced by the courts to pay the requested amount, with no recourse?


    No. But in this case, it's not the RIAA that picked the $750 figure; it's the law itself. The whole point of statutory damages is to deal with the cases where computing real damages is difficult or impossible. In general, it's a reasonable system; it saves time and effort from both sides and arrives at a reasonable figure.

    In this case, though, the defense is arguing that the statutory amount is so unreasonable as to amount to a violation of due process (presumably unreasonable seizure? I'm not sure what the exact grounds for the argument is).

    But the RIAA aren't the ones making up the $750 figure; the law specifies it. If the RIAA had picked a number, there would be no question that the defendant would be allowed to challenge it; this case is unusual because the defendant is mounting a constitutional challenge to a legislatively-chosen statutory amount.

    See 17 United States Code s504 (c)(2):

    1) Except as provided by clause (2) of this subsection, the copyright owner may elect, at any time before final judgment is rendered, to recover, instead of actual damages and profits, an award of statutory damages for all infringements involved in the action, with respect to any one work, for which any one infringer is liable individually, or for which any two or more infringers are liable jointly and severally, in a sum of not less than $750 or more than $30,000 as the court considers just. For the purposes of this subsection, all the parts of a compilation or derivative work constitute one work.
  15. Re:Windows on How Many Windows? · · Score: 1

    Personally, I don't care whether I kill the PC a couple of years earlier or not - it's going to be replaced anyway, and that includes the PSU, because whatever you have in there is going to be too small next year, anyway.

    In my case, that lost life is more than compensated for by the power savings I make, on a regular basis, by having as few electronic devices powered up as possible.


    If you're as penny-pinching as you purport, consider throwing in an extra year or two between new machines. I'm always shocked when non-gamers get new machines every 2-3 years (especially my parents who will sometimes buy a new one because "it got a virus we can't cure" or similar weirdness). If the machine is in (non-buggy) suspend most of the time, you're saving _maybe_ $3-4 a month (and that's at the outside) by turning it off; going from 3 to 5 years between $1000 machines would save substantially more.

    Heck, I'm a hardcore slashdot geek and professional programmer, and my machine from c.2001 is still fine; it'll probably be replaced in another 2-3 years. It's not the most blazing thing in the world, but honestly since machines hit 200mhz with 128MB of RAM there just hasn't been the same return on bigger, faster, newer! that there used to be unless you're really into power gaming.

  16. Re:Forget the environment then... on How Many Windows? · · Score: 1

    What's this idea of my computer "using" energy? It transforms electricity to heat. I would be producing heat with electricity anyway, because it is autumn/winter. Keeping my computer and lights and stuff on makes no[1] difference to my electricity bill - it just gives me utility for the power that would otherwise go to my electric heater.

    If you're using a resistance-coil electric heater you have worse energy problems than the computer. Even a heat pump can outperform resistance heating by a factor of 2-3 or more.

  17. Re:Windows on How Many Windows? · · Score: 1
    What is the point in shuting your machine down?

    Because it's a horrible waste of energy?

    It's possible to get the energy use down pretty low. My system was primarily configured to be silent other than the hard drives, which are aggressively spun down when not in use; side effects are cool (low-power) graphics card/cpu, a fanless setup, and a small power supply. It uses a fujitsu-siemens* energy saving motherboard that clocks down the CPU when it's not working hard, and suspends the CPU/monitor and steps down the power supply when the machine is idle.

    It draws very little power when it's suspended, but it only takes a couple of seconds to come back to life.

    HINT: I was wondering why power savings wasn't as low as I had hoped in power-saving mode--took me a while to figure out that the wireless ethernet card I have still draws a fair amount of power when the machine was suspended. I'm not sure if that's a common problem, but consider wired networking for low-power machines.

    *The F-S motherboard in question is also very low lead, which is a nice small environmental bonus.
  18. Re:Hubris! on Hiring (Superstar) Programmers · · Score: 1

    So you're saying you would turn down any job that had as a stated requirement that you are on call at all?

    In the past, I have turned such jobs down. I can't say I'd turn them all down, for the right amount of money I'd consider a few nights a month, but I've taken $15,000/year less to avoid being on call about 1 week a month. I'm probably a bit more sensitive than most as my dad is a doctor and growing up he was on call 1 night in 3; to me, the value of having my own time be _mine_ is pretty high.

    I certainly wouldn't give my personal cell number to a job unless I really knew the employers and trusted them to use it only in true emergencies.

  19. Re:Finally... on Motorola Develops Bare-Bones Phone · · Score: 1

    Things I don't care about:...
    Thickness---who cares? It goes in my pocket.


    This I don't understand. "It goes in my pocket" is exactly why thickness is pretty much my #1 distinguishing criteria* for buying a phone. The original startac was just barely thin enough to carry comfortably in my pocket with nothing else in there, the razr is just thin enough that I don't have to worry about whether I accidentally put it in the same pocket with my wallet or not.

    I don't understand how your phone is warping or snapping in half--you're not putting it in your back pocket and sitting on it are you?

    A slide switch to lock the phone, just like the hold switch on my iPod... or maybe a sturdy slide cover over the digits that disables all the other functionality except when it is fully open.

    Yes, please. Not a huge problem with a clamshell but still would be nice.

    No large LCD panel at all. It should have about two lines of display---enough for a phone number and a name.

    Yeah. Having 2(!!) LCDs both in color (a la the razr) is just a waste for most people.

    *Which is a sad commentary on how much modern phones compete on criteria I don't care about and are pretty similar on the things I do.

  20. Re:Finally... on Motorola Develops Bare-Bones Phone · · Score: 1

    Of those, caller ID is the only one I'm interested in and that was already in the "simple" phone I want to find a modern equivalent to (the original Motorola StarTac).

  21. Re:Hubris! on Hiring (Superstar) Programmers · · Score: 1

    There was supposed to be, don't get me wrong, the company provided advice to help keep home and work separated, such as to keep a separated work area, and only work when in that room of the house, but it just didn't work. I would get calls in the middle of the night, dinner, etc, asking me if I was still working, and then providing me with lots of work.

    #1 piece of advice: work never gets your personal cell number. Either get a seperate land-line for the home office or get a work cell phone that you turn off when you're no longer at work--or, if they want you to have it on, they pay for it and you negotiate hours and rates.

    One of the key things I always clarify before accepting any tech job is that I don't carry a work cell and I don't do on-call, outside of special circumstances. (If we have a major new server system launching that needs developers on call around the clock for a few days until we're confident, that's fine as a once every year or 18 months thing).

  22. Re:Ignoring a potential talent pool on Hiring (Superstar) Programmers · · Score: 1

    It's a website, surely they could handle remote coders?

    Part-time remote, sure. But usually more than 50% of a typical web programmer's job is meeting with the end-users (or spec developers) to figure out exactly _what_ they want--something they think they know from the outset but rarely do. Writing the code is usually relatively easy, and can be done off site.

  23. Re:30th birthday of what exactly? on 30 Years of Public Key Cryptography · · Score: 1

    I just feel the Americans deserve a hell of a lot more credit for this stuff because without RSA we might never have gotten public key cryptography

    Diffie/Hellman/Merkle's work was pointing the way; I have to think public-key would've happened in relatively short order (within 5-10 years) without RSA.

  24. Re:Missing info on Deprecating the Datacenter? · · Score: 1

    It's like the myth that computers will create a paperless society. Computers just help us create more stuff to put on the paper. Sure you could bring a computer with you everywhere, and distribute everything on the internet, so we wouldn't need to use paper. It sounds like a nice idea, but in reality, it never ends up happening that way.

    I don't understand why it won't. I've gone _way_ down in the amount of paper used in the last decade; e.g., all my bills and billpayments are paperless now. I still get receipts in stores and things like that, but I can't remember the last time I used a stamp or turned my printer on (the latter is still boxed up from my last move 3 years ago).

  25. Re:An interesting observation on Great Programmers Answer Questions From Aspiring Student · · Score: 1

    Bentley's Programming Pearls is mentioned both by James Gosling and Tim Bray. For my part, I was surprised nobody mentioned the design patterns book.

    That's because design patterns isn't a CS or programming book per se, it's just an attempt to put a uniform set of names on practices that were widely used long before it came out. It really is just an attempt to create a jargon, which is valuable in enabling communication if done well (Design Patterns did a reasonable job; in some areas they're heavily skewed toward statically typed languages, so parts of the lexicon aren't really general across things like Smalltalk, Lisp, Python, Ruby, etc; a great deal of it does transfer okay though). Along the way it can help crystalize some of the thoughts you've had about particular patterns, but it's not a good source for learning programming patterns you haven't used before. Certainly you _could_ learn them from it with enough effort, but that'd be sort of like learning C or Java from the standard.

    SICP, Programming Pearls, K&R, etc are all good books to learn facets of programming from. Certainly all of them deserve a spot on the shelf of a programmer--be it an architect, software engineer, computer scientist, or working coder--long before Design Patterns.