IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New C++ - the stupidity continues
To make a buck and not end up homeless I'm presently torturing a bunch of freshman geeks at the local state college with my rendition of "Introduction to Programming - C++".

Today I will introduce the streams library. Since I haven't used the new streams library, only the old one as documented in the fish book, I have been playing catchup and writing little programs.

One nice little advancement is the introduction of a string class into the language that is also stl compatible. Nifty, use it all the time, no more char arrays. The entire strstream lib has been rewritten to use it for internal storage ala Smalltalk streams. Fine. Love it. Although I rather miss being able to do

char buf[len];
ostrstream(buf,len) << something << ends;

to do in memory formatting, having a string object is really good too.

PITY THE FUCK WEASELS DIDN'T BOTHER TO LET YOU SPECIFY THE FUCKING FILE NAME FOR A FILE STREAM USING IT. THAT'S RIGHT, YOU GOTTA SPECIFY THE FILE NAME AS A FUCKING CONST CHAR *.




Democracies are not well-run nor long-preserved with secrecy and lies.

     --Walter Cronkite
New AHHHHH.... Good to see you posting...
How ya doing?

On the other hand, ain't it nice you only get half the change... :)

No really, there was a reason for this... truly a reason of magnitude...

Why you ask?

Well, I'll tell ya, I was going to just make it plainly obvious.*PLONK*

ahh... ohh.

Yeah, because it wasn't purty and didn't flow well. Yah know, code is a thing of beauty.
--
[link|mailto:greg@gregfolkert.net|greg],
[link|http://www.iwethey.org/ed_curry|REMEMBER ED CURRY!] @ iwethey
No matter how much Microsoft supporters whine about how Linux and other operating systems have just as many bugs as their operating systems do, the bottom line is that the serious, gut-wrenching problems happen on Windows, not on Linux, not on Mac OS. -- [link|http://www.eweek.com/article2/0,1759,1622086,00.asp|source]
Here is an example: [link|http://www.greymagic.com/security/advisories/gm001-ie/|Executing arbitrary commands without Active Scripting or ActiveX when using Windows]
New Good to see you again!
You didn't expect C++ to make sense, even after all these years, did you?

;-)

Cheers,
Scott.
New TB hola brother!
I'm broker than you neener!

'Course I only got a sister to worry about...

I remember slapping my forehead here about a similar issue some time ago.
-drl
New They what?
You mean that you have to hard-code the filename in your code?

What use is that?

Ben
To deny the indirect purchaser, who in this case is the ultimate purchaser, the right to seek relief from unlawful conduct, would essentially remove the word consumer from the Consumer Protection Act
- [link|http://www.techworld.com/opsys/news/index.cfm?NewsID=1246&Page=1&pagePos=20|Nebraska Supreme Court]
New Not quite
there's a method on string to get a pointer to the internal character array. You have to call that.

string filename = "myfile.dat"

ifstream fin(filename); // doesn't work

has to be

ifstream fin(filename.c_str());

Mighty lame.



Democracies are not well-run nor long-preserved with secrecy and lies.

     --Walter Cronkite
New Ugly, but not a critical flaw
To deny the indirect purchaser, who in this case is the ultimate purchaser, the right to seek relief from unlawful conduct, would essentially remove the word consumer from the Consumer Protection Act
- [link|http://www.techworld.com/opsys/news/index.cfm?NewsID=1246&Page=1&pagePos=20|Nebraska Supreme Court]
New Pretty much sums up C++
New It's totally against the original spirit
It's like C++ consuming itself. A natural idiomatic expression turns out to be impossible.

IIRC you can get around even this stupid requirement with nastycasting.
-drl
New No, just pointlessly inconsistent
Which makes for pointless wastes of time having to look up all the shit that doesn't work the way you'd think it ought to all the time.



Democracies are not well-run nor long-preserved with secrecy and lies.

     --Walter Cronkite
New Re: No, just pointlessly inconsistent
Definition of a good idiom: One that doesn't imply its own self-inflicted defeat.
-drl
New Per Barney:
Conversion to a C-style string could have been provided by an operator const char *() rather than c_str(). This would have provided the convenience of an implicit conversion at the cost of surprises in cases in which such a conversion was unexpected.
--The C++ Programming Language -- Special Edition Bjarne Stroustrup.

So there you have it! The Framers were trying to protect you from youself. Just like Java! Rejoice and be glad in their thoughtfulness!

;-\ufffd

(For what it's worth, I don't like it either!)

So here's a suggestion: With all the wry (or rye) sarcasm you can muster, helpfully point out to the class the thoughtful parochialism of the Framers, and then suggest the creation of a derived sString class, (for smart String) that defines an overload of operator const char *(), and strongly suggest (read: demand) that this derived class be used in all your assignments. It would extend your class's understanding, and would give some useful metrics on how often (or whether) such parochialism was a hindrance as opposed to a help. (I suspect I know what these metrics will show, but real-world numbers trump my suspicions any day of the week and twice on Sunday!)
jb4
shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT

New It's stupid
Idiomatic expressions should work without handsprings. They used to, in the "better C" days.
-drl
New No, I agree with the decision
to avoid the op const char*. Although I think leaving it out is a violation of the design philosophy of C++, which as far as I can tell is to follow "The Principle of Most Surprise".

OTOH, I think its totally stupid to have a whole chunk of streams library implemented in terms of string ([io]stringstream) and then not have a ctor for [io]fstream that allows you to use the string.




That was lovely cheese.

     --Wallace, The Wrong Trousers
New Agreed...but...but...
Yes, the [io]fstream most assuredly should support a string constructor (and a wstring constructor, as well). But don't you know that the [io]fstream stuff was supposed to be a "better stdio that stdio?", and so thererfore would have to support analogs to stdio's [f]open? Maybe they just took the analogs a bit too literally.

Besides, I think what really happened is that in pre-ANSI stream libraries, there was no string class (at least, not a standardized one that anyone could count on being there); instead, there was a mish-mosh of non-standardized ASCII character containers, many of which were called string. By allowing the one true string class to be used as an option, it could well have broken existing compilers implementations of their proprietary garbage. Both X3J11 (ANSI C) and X3J16 (ANSI C++) committees went through hoops to try to minimize breakage of existing code (IMHO, to the detriment of both languages), and it was probably thought that the risk of breakage was too great.

I would expect that C++ V2.0 would fix this rather egregious omission, and to hell with anybody's code that it breaks!
jb4
shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT

New Hooray! Todd's back! :)
     C++ - the stupidity continues - (tuberculosis) - (15)
         AHHHHH.... Good to see you posting... - (folkert)
         Good to see you again! - (Another Scott)
         TB hola brother! - (deSitter)
         They what? - (ben_tilly) - (10)
             Not quite - (tuberculosis) - (9)
                 Ugly, but not a critical flaw -NT - (ben_tilly) - (4)
                     Pretty much sums up C++ -NT - (JayMehaffey)
                     It's totally against the original spirit - (deSitter)
                     No, just pointlessly inconsistent - (tuberculosis) - (1)
                         Re: No, just pointlessly inconsistent - (deSitter)
                 Per Barney: - (jb4) - (3)
                     It's stupid - (deSitter)
                     No, I agree with the decision - (tuberculosis) - (1)
                         Agreed...but...but... - (jb4)
         Hooray! Todd's back! :) -NT - (FuManChu)

With the mochas he was strong.
107 ms