Slashdot Mirror


User: Venomous+Louse

Venomous+Louse's activity in the archive.

Stories
0
Comments
307
First seen
Last seen
Profile
(view on slashdot.org)

Comments · 307

  1. Hey, that's slick. on Ask Bjarne Stroustrup, Inventor of C++ · · Score: 2


    One problem I can see, though, is that if each of the blocks can have > 1 T instance in it, what happens when you start erasing? Oh. Never mind: You just keep track and reuse 'em. Placement new, placement delete. No problem. Uhh, wait a minute . . . you'd have to be writing your own allocator, or something very much like it. One way or another, you've got to be keeping track of the gaps in those blocks. That'll be a pain in the ass. Why not just allocate each T instance separately with new? In that case, it's an option that's available with the normal std::vector; that's usually how I use them. If I need to worry about keeping something sorted, I generally use std::map anyhow. I get the feeling I'm missing at least part of your point here, but I'm enjoying it anyway :)

    Now, the problem that is left over, is the problem of taking a pointer to *(vec.begin()) and passing it to a C function that expects an array of T. That ain't gonna work.

    Additionally, this vector impl may be a lifesaver if the space taken up by the objects you wish to put in the vector comes perilously close to exhausing your virtual memory.

    Errr . . . how so?

    (btw -- re: your other post in this subthread: Didn't I mention something about copy constructors? I don't see a need for the move thing, unless you could gain serious efficiency with it. Anything you're storing in a std:: container needs a copy constructor anyway, right? Requiring a copy constructor is nothing new.

    ---------------
    Disclaimer: AFAIK, IIRC, YMMV, IANALL (I Am Not A Language Lawyer), u.s.w.

  2. More like this on Ask Bjarne Stroustrup, Inventor of C++ · · Score: 2


    The type T2 in the case below need not and should not be fixed when the class template is instantiated. You might want to call the functions that use it three different times, with three different T2 types. That's the only reason to bother parameterizing the type in the first place.

    What would be gained here is defining the callback type once, out in the open. As the language presently stands, this code can be written, but it would be ugly, as we see in the example.

    template<class T>
    class container {
    template<class T2>
    typedef bool (* callback)( const T &r, const userdata &ud );

    // for each contained item, call the callback and pass it a
    // reference to the current item and a reference to userdata
    // This is nice but illegal.
    template<class T3>
    void traverse( const T3 &userdata, callback<T3> cb );

    // This is why it would be *really* nice to have the typedef;
    // we may want it more than once.
    template<class T3>
    void traverse_reverse( const T3 &userdata, callback<T3> cb );

    // This legal code is what I'd like to avoid
    template<class T3>
    void traverse_ugly( const T3 &userdata,
    bool (* callback)( const T &, const T3 & ) );
    };


    The question really is, "is this ugly enough to make it worth anybody's while to add a feature to the language?" I suspect that the answer is "no", since it'd be merely a convenience which would add no functionality.

  3. The fundies will win (for the time being) because on Lightning Crashes, An Old Freedom Dies (Updated) · · Score: 4


    . . . You can always tailor a lie to be exactly what the audience wants to hear. You can't do that with the truth: Lies have the property of still being lies if you change them; the truth isn't like that, and it's very rare that the truth happens by chance to coincide with what people want to believe. As long as human nature doesn't magically change, most people will believe anybody who tells them what they want to hear, and fundies and other professional swine will be able to manipulate people to gain power.

    We're stuck with it.

  4. Re:Hmmm, right . . . on Ask Bjarne Stroustrup, Inventor of C++ · · Score: 2


    I can't see how to implment it with the time-complexity requiremnts demanded without it being an array (plus a little bookkeeping).

    Yeah, I can't think of anything either (not that I'm an algorithm guru by any means). Still, I'm down with the idea that the interface should be guaranteed, but not the implementation.

    why don't you take the SGI STL vector class, rename it, and use it.

    Uhhh, good question :)

  5. Hmmm, right . . . on Ask Bjarne Stroustrup, Inventor of C++ · · Score: 2


    . . . and the STL probably does it with placement new/delete and writing their own allocator. In fat, I seem to recall that placement new and placement delete were added at least partially to keep Stepanov happy . . .

    I guess the implications may well be weirder than I think they are, but it still seems kinda constricting. One question is this: Is it guaranteed that a pointer to item zero in a vector<foo> is in fact a pointer to a contiguous block of memory holding an array of foo? People still have to interact with old C libraries, and people can (and do) derive classes from old prehistoric structs. If I've got a vector of foo, and some function expects a pointer to an array of a struct from which foo is derived (with no additional data members -- I wasn't born yesterday :), where does that leave me? Stroustrup 3 ed 16.3 is not helpful. If std::vector does, in fact, guarantee the above, I'll be a happy camper. I'd also stop and think next time I called erase() on one of 'em :)

  6. Also: Why no "realloc( )" for new[]/delete[]? on Ask Bjarne Stroustrup, Inventor of C++ · · Score: 2


    Something like operator renew[] would be useful. I often still use malloc()/free() because I get to use realloc() with those. Still, if I've got an array of class instances, I'm S.O.L. Granted, operator renew[] would be inefficient and it would require copy constructors on everything, but C++ generally assumes that the programmer has enough sense to come in out of the rain. There are other "caveat user" things in the language already: Take for example pure virtual functions, which a naïve programmer is perfectly free to call in a base class constructor. This would just be another one of those (though you might say there are too many booby-traps already :)

    Certainly one could approach this by overloading operator new[] and operator delete[] and writing an operator_renew() function template using placement new /placement delete , but that would be tedious and goofy. You'd have to write your own allocator.

  7. Read _The Design and Evolution of C++_ on Ask Bjarne Stroustrup, Inventor of C++ · · Score: 2


    The original poster asks a good question: is C++ more efficient for those lower-level things (things that would form an operating system kernel, or microkernel servers) than traditional languages (C and architecture assembly)?

    Stroustrup's The Design and Evolution of C++ is a fun read, and it addresses that question. The intent was apparently that C++ would be as close as possible to the efficiency of C, and in fact that was something of a litmus test for new features: "Can we do this efficiently enough that C programmers won't make fun of us?" I myself don't know enough about that low-level stuff to be able to comment on the details. YMMV, etc. etc.

  8. Why no templated typedefs? on Ask Bjarne Stroustrup, Inventor of C++ · · Score: 5


    Well, this is weird. Just the guy I wanted to talk to this morning!

    It would occasionally be handy to have typedef templates (or template typedefs?! help!), something like this:


    template< class T >
    typedef bool (* func)( const T &r );


    . . . but that doesn't seem to be legal. I don't recall seeing anything about this issue in The Design and Evolution of C++. So what's the deal?

  9. Hmmm. on Borland C++ Now Free-as-in-Beer · · Score: 2


    member templates are supported as long as they are inlined.

    See Appendix I; I'm not certain that they're doing the right thing, but then again I'm not certain that I'm doing the right thing either :)

    Namespaces support has been much improved in version 6.

    I didn't know there was anything wrong with it before. I don't use namespaces much, though, aside from the STL :)

    I still insist that VC6 is fairly ANSI compliant. I'd say it's on par with GCC 2.95

    That's good news about GCC (do they have namespaces yet?); I'd thought that MSVC was pretty close to the mark in most respects. I mean, yadda yadda I hate Microsoft and all that, but I don't get all that emotional about compilers unless something specific that I need is broken. The things that really annoy me about MSVC 6 are GUI problems, extra annoyance popups and whatnot.

    ------------------------------------------------
    Appendix I

    Here's what I'm talking about with member templates of templates. Note that this code won't compile, and note also that I'm not ruling out a bug between my own two ears:

    #include <stdio.h>
    #include <string.h>

    template <class T>
    class foo {
    public:
    // Here's the member:
    template< class T2 >
    void traverse( const T2 &r2, bool (* callback)( const T &r, const T2 &r2 ) )
    {
    for ( int i = 0; i <= size; ++i )
    if ( ! (*callback)( data[i], r2 ) )
    break;
    }

    T * data;
    int size;
    };

    bool callback( const char &c, const char * const &fmt )
    {
    printf( fmt, c );
    return true;
    }

    int main()
    {
    foo< char > f;
    char * crap = "vogon";

    f.data = crap;
    f.size = strlen( crap ) - 1;

    // All this over-specific crap is an attempt to get the compiler to admit
    // that I'm doing what I'm doing; but it insists that T2 is ambiguous:
    // it thinks it could be either const char * or const char *const &
    // FWIW I'm seeing the same error with MSVC 5. I'm not certain whether it
    // *should* be considered ambiguous or not. I'm also not so sure about
    // casting to a reference :) Oh, the joys of C++. How many angels can
    // dance on a const reference? You have a right to secure counsel from a
    // language lawyer.

    const char *fmt = "char: '%c'\n";
    const char * const &fmtr = fmt;
    f.traverse( (const char * const &)fmtr, callback );

    return 0;
    }

  10. Did they fix the template problems in MSVC 6? on Borland C++ Now Free-as-in-Beer · · Score: 2


    Like for example a member template function of a template class was totally beyond the comprehension of v5. Uh, what I mean is this: You've got a class template, and it's got a member function which is a template unto itself, with its own type parameter(s) unrelated to those of the class. GCC 2.8.1 grokked that, but MSVC 5 got upset. I don't recall what BCC did. (I spent a weekend once trying stupid template tricks with those three compilers, finding a subset that would compile on all three). Also v5 couldn't seem to cope with a member template function of a normal class unless the body was defined in the class declaration. That's tolerable, I guess, but still vaguely annoying. It's also possible that this shit is supported, but I never quite figured out how to *declare* it! ;) Ha ha! Fucking Stroustrup . . . But the fact is, it worked in GCC 2.8.1, and it worked the way I expected it to. Of course, GCC 2.8.1 doesn't have namespaces and other stuff, so it's not like anybody's perfect . . . Have they fixed that yet in GCC, I wonder?

    Somebody's gotta get that damned name-mangling thing sorted out. What a crock.

  11. Link libs != DLL's on Borland C++ Now Free-as-in-Beer · · Score: 3


    The link libs are incompatible. That's what you use implib for. It generates Borland-friendly link libs from arbitrary DLL's. MSVC doesn't have an analagous utility (BTW MSVC 5 is violently unable to cope with MSVC 6 link libs if they've got a $debug section, ha ha -- found that out the hard way, installed MSVC 6, and wasted a day and a half fixing the damage to my system from the "upgrade"). 32-bit windows DLL's are goddamn PE files, they all have the same header and the same sections and blah blah blah. You're talking out your ass.

    If you don't like the struct alignment, change it. Compilers can do that.

    For anybody in the audience not familiar with dynamic linking in Win32: The library is called foobar.dll, and it comes with a smaller file called foobar.lib, which is what you "link" to, and which contains basically the names of the exported functions and not much else. The compiler groks all this.

  12. MFC is crap on Borland C++ Now Free-as-in-Beer · · Score: 2


    There are other class libraries out there that are actually worthwhile (e.g. Borland's VCL, hint hint). There's gotta be a GTk port, too -- or, as you say, you can write your own. It's not monumentally difficult if you're willing to blow off portability, and if you're at all competent it won't take but a few weeks (I've done it), which you can amortize over the remaining lifetime of the Win32 API. For your time investment, you'll free yourself from the misery of wrestling with MFC's bizarre limitations and idiotic design flaws. A C++ library should be written (not to mention designed) by people who know C++ and OOP reasonably well. MFC wasn't. The Win32 C API was at least designed by people who knew their way around the paradigm they were working with. It's not perfect, but it's acceptable.

    Now that I mention it, Win32 programming in C with just the API isn't anybody's worst nightmare. It's ugly and painful because GUI's really demand OOP, but I've done it and honestly it's not much worse than MFC.

    Is there any GPL'd MFC code out there at all? I'm inclined to doubt that, unless Al Stevens uses the GPL. Stevens isn't doing anything real crucial anyway.

  13. Re:NAACP == "guilt"?! You're insane. on A New DeCSS · · Score: 1


    I'd just like to let you all know that I decided against making a horrible felon/feline pun at this point.

    I humbly thank you for your restraint :)


  14. NAACP == "guilt"?! You're insane. on A New DeCSS · · Score: 2


    Point: Ms. Parks wasn't the innocent history claims she was. She was the Boss of the local chapter of the NAACP. She knew what she was doing.

    Yeah. She was, in a harmless way, violating an unjust and immoral law, which happened also to be unconstitutional. Of course she knew what she was doing: She was standing up for her rights as a citizen.

    In any case, if you think membership in the NAACP somehow precludes "innocence", you're out of your mind.


    They know this is illegal, but post it anyway. You're hardly innocent.

    I think you've just raised bootlicking to a new peak of perfection. Calling a program "DeCSS" is not illegal. In fact, I'm going to rename my cat "DeCSS". There, it's done. I'll be calling him that from here on in. No doubt you think that makes me a felon.


  15. I *know* you never said "debugging"; *I* did. on Women CS Majors Declining · · Score: 2


    I NEVER said anything about "debugging".
    Re-read what I've written.


    I don't have to re-read it; I believe you. You were speaking only about programming in general. Debugging is, however, part of programming, and it's an important skill. I'd give a lot to be better at it.


    I completely agree with you on your debugging-story, but that's offtopic. I never used that word.

    I don't personally see debugging as being very far off-topic in a discussion of programming.

    All I said was that you said something along the lines of "think about it", and I did, and that's what came out. I'm not seeing an argument here at all.

  16. Well, then. on Women CS Majors Declining · · Score: 2


    In 22 years I saw 98% of female programmers quitting, because they just couldn't do it. They TRIED HARDER THAN EVERY OTHER MAN, but they still couldn't do it.

    You may have seen that, though people usually see what they want to. In any case, it's not relevant. I wasn't claiming to have "proven" that women can code (though I've known a few women programmers, and they succeeded at about the same rate as men). That wasn't my point at all. My point was that you were telling us all about how women's minds work, and what you were describing is somebody who'd be good at debugging. Well, then, either women are good at debugging (which is only one part of programming, by the way), or else your description is not as accurate as you think. Hey, it might even be both.

    In any case, I didn't have an "argument". I just looked at what you'd posted, drew a conclusion that seemed obvious to me (obvious enough that it really jumped out), and threw it out for discussion. Focussing too narrowly can make it very damn hard to find bugs. In my experience, the bug is not often where I think it is, and I'm very often led to it by noticing some small thing that I missed the first few times I stepped through. On the other hand, there's more to programming than finding bugs. Hell, there's more to human beings than a few oversimplified orthodoxies. I'm not claiming to have any answers, nor am I trying to start a flame war. If I created that impression, I apologize.


  17. Hmmm . . . on Women CS Majors Declining · · Score: 2


    IMHO you're both exaggerating and overgeneralizing, but I'm not a sociologist. At any rate, if everything you say is absolutely accurate, why then I'd say that it's no wonder so much software is so damn buggy. Tour description of women sounds like somebody who'd really kick ass at debugging, but programming is a predominantly male profession (or schtick, or racket, or whatever you want to call it :)

    Just a thought. I don't take it very seriously, but you asked us all to check your examples, and I did.

  18. Re:This is not a stupid idea, *except* . . . on OpenLaw to Support Open Source Community · · Score: 2


    I can tell you that the technical perspective is something that many lawyers including Tech and IP lawyers are lacking. The help that many of the people here could offer could be quite powerful.

    Hmmm . . . From that perspective, it suddenly begins to make some sense. I'd taken the article to be proposing that we ask Slashdotters about the law, which would be nothing but a hindrance. It would be like asking lawyers about technical issues. But as you say, both groups need to be better acquainted with each other, and that's something we can probably help with.


    Now the only problem is her understanding "Natalie Portman petrified in Hot Grits"

    :) Hey, those guys at least tried to be funny. Compare to the spam nowadays, and they come off damn well.


  19. You sorta missed the point. on OpenLaw to Support Open Source Community · · Score: 2


    My point is that computer geeks are rarely lawyers. I Am, as they say, Not a Lawyer. Nor are you, I'm willing to bet.

    The answer to most legal questions is "ask a lawyer", not "ask Slashdot". Would you hire a programmer to write code? Hell, I wouldn't even hire most Slashdotters to write code -- and they know more about that than they do about the law.

  20. This is not a stupid idea, *except* . . . on OpenLaw to Support Open Source Community · · Score: 3


    The word of the day is "pro bono". Lawyers have been doing voluntary community service for a long, long time. The eyes of many lawyers probably will make "bugs" shallow.

    However.

    As far as law is concerned, the eyes of a million SlashBots are worth about, oh, golly . . . I don't think they make numbers that small. How's this: That and a dollar will get you a 50-cent cup of coffee. Just barely.

    I can see it now: "IT"5 ALL ABOU7 THE SEC0ND AM3NDM3N7!"

    God help whoever as to wade through the email on this one.

  21. Erm, uhhh, whuh? on Why Linux Makes Sense for India · · Score: 1


    all poor people are lazy and deserve to be killed

    That's a disgusting overgeneralization. I have certainly advocated wounding the poor on more than one occasion, but never killing them . . . unless they're driving slowly in the left lane, of course, but that's a capital crime when anybody does it.


    Nice troll, by the way. Not bad at all. It took me a minute to grok.

  22. Clemson is a state college. on Clemson University Bans Free Long Distance Sites · · Score: 3


    Clemson's "customers" are better known as "taxpayers". If they kids aren't paying taxes, then they're not working and their parents are paying their tuition -- and the parents are working, I'll bet. And taxes pay for a big, big chunk of what happens at a state school.

    Very different rules apply to a public institution and a private business. A state college is a public trust, paid for by the public and managed for them by the state. A business is owned by and responsible to its shareholders alone, or to an even smaller group if it's privately held. Clemson is the government, and it has no damned business protecting its interests at the expense of the taxpayers' interests, because its only legitimate role is to act in the taxpayers' interests.

    But I suspect that you merely guessed wrong about the ownership of Clemson, and the above is pretty much what you'd be saying if you knew it was a state school. Of course, you might also suggest that the state has no business running colleges, and as a matter of fact I might well agree. But that's another discussion entirely.


  23. One point of disagreement on UN Wants to Combat Online Racism · · Score: 1


    I'll buy most of what you're saying, with the exception of the following:

    Refusing to step down from power despite the fact that his continued presence perpetuates the embargo, causing starving and needless suffering for his people.

    If I start beating youf wife, and I promise to stop when you divorce her, who's the asshole? Me.

    Saddam Hussein is not responsible for the actions of the US. If somebody came along and organized an international embargo of the US (we do have a lot of foreign trade, and it would be a very bad thing), and if they promised to stop if we would only hang Bill Clinton up by his heels, what kind of a reaction do you think that would elicit from the American people? Clinton's popularity would rise. Yeah, some of them would want to go along with it, but a lot of people have strong feelings about the whole sovereignty thing, and not all of those people live in bunkers in Idaho.

    Bowing to threats is not generally considered honorable or decent behavior. The fact that "our side" is the one doing the threatening is irrelevant.

  24. This AC posted the "37337" trolls himself. on Hoberman Sphere Building Blocks · · Score: 1

    Some poor dumbass with a lot of time on his hands and a senseless grudge against somebody he's probably never even met. Get a life, stupid.

  25. Re:Do they? [way, wayyyyy OT] on Virtual Newscaster · · Score: 1


    Seriously, though, people have been putting forth the same "the machines will take all of the jobs! or at least the poor people's jobs, anyway" argument for about 200 years now. It hasn't happened

    First, the fact that it hasn't happened yet doesn't prove that it can't ever happen, any more than that proves that it will happen. I think you've demonstrated some room for optimism there (more optimism, to be specific, than I offered in my post), but I don't think you've proven anything.

    Second, there is a widening gap between the rich and the poor in the USA, and for the urban poor in particular things are getting increasingly ugly as time passes.

    Third, cultures have collapsed before because the sans-culottes (or descamisados or proletariat or whoever) got to a point where the majority of them simply had no way of getting a square meal.


    There are a huge number of assumptions implicit in those two sentences.

    The more the merrier! :) You're right, but I think some of them are at least somewhat justified, as follows:


    -things could get "that bad" for a lot of people

    See "sans-culottes" above; it's happened before in history. IMHO the burden of proof is on anyone who claims that it can't happen. This, of course, does not necessarily imply that it's happening right now, as we speak, in NYC.


    said "real bad"ness will make other people change their beliefs about things like freedom

    I didn't clarify that, but I'll stand behind it 100%, as soon as I get a chance to fill in the rest of the thought: A-hem. If/(when?) the proles (for lack of a better term) feel that they have nothing to gain by following the rules, they're going to stop following the rules in a big way. When that happens, the people who still have something to lose will be all in favor of draconian law-enforcement measures and a serious erosion of the rights of groups perceived as being poor and/or criminal. In general it's a valid observation about a state of affairs which does arise now and then in this world. If NYC is not now in that state, I should obviously not have mentioned it.


    New York is already "real bad", and is already a police state,

    Okay, then what is it? That's not sarcasm, I'm curious. The Giuliani fans I've spoken to (and read in the press) have claimed that crime in NYC was beyond endurance and that extreme measures were therefore necessary and justified. Life being as complicated as it is, there is no doubt more to be heard about the subject.


    and this meets with the approval of "freedom-loving affluent geeks"

    I may have been mistaking the views of noisy tough-on-crime Slashdotters with the views of a larger group of people. If so, I goofed. However, it's a very, very common phenomenon, geeks or no geeks.


    Hey, if you want, I can put you in touch with the NY libertarian mailing list

    By all means, I'd appreciate that very much.