Topic: string::case_sensitive_flag


Author: maxtal@physics.su.OZ.AU (John Max Skaller)
Date: Sat, 15 Jan 1994 06:23:40 GMT
Raw View
In article <1994Jan12.203343.29997@sjsumcs.sjsu.edu> horstman@sjsumcs.sjsu.edu (Cay Horstmann) writes:
>The Borland C++ 4.0 implementation of the proposed ANSI string class
>(but not the notes that I have from the pre-San Jose distribution)
>uses static flags for
> - paranoid check
> - skip white space
> - case sensitive
>to be used with string operations. For example,
> string::set_case_sensitive(0);
> string s, t;
> if (s < t) // now does stricmp
>Is this part of the standard, or a Borland enhancement?

 Enhancement. As I've argued many times, the Standard Library
string class is inadequate. Its natural for implementors to
provide extensions to make up the inadequacy and all do it
differently.

>
>It seems like a poor design to me. While I may agree that paranoid checking
>could be global -- you are paranoid or you are not -- skipping white space
>is clearly not, and a function that forgets to restore the white space
>flag can mess up a program.
>
>A better alternative would seem to reserve the relational operators for
>strcmp and give string::compare(const string&) const a second optional
>explicit argument with the flags to use.

 There are many better alternatives.
And that is the problem. My solution: use your own string class :-)
That, being written in Standard C++, will be portable between
systems, even if it does not interface to other string classes.

--
        JOHN (MAX) SKALLER,         INTERNET:maxtal@suphys.physics.su.oz.au
 Maxtal Pty Ltd,      CSERVE:10236.1703
        6 MacKay St ASHFIELD,     Mem: SA IT/9/22,SC22/WG21
        NSW 2131, AUSTRALIA




Author: horstman@sjsumcs.sjsu.edu (Cay Horstmann)
Date: Wed, 12 Jan 1994 20:33:43 GMT
Raw View
The Borland C++ 4.0 implementation of the proposed ANSI string class
(but not the notes that I have from the pre-San Jose distribution)
uses static flags for
 - paranoid check
 - skip white space
 - case sensitive
to be used with string operations. For example,
 string::set_case_sensitive(0);
 string s, t;
 if (s < t) // now does stricmp
Is this part of the standard, or a Borland enhancement?

It seems like a poor design to me. While I may agree that paranoid checking
could be global -- you are paranoid or you are not -- skipping white space
is clearly not, and a function that forgets to restore the white space
flag can mess up a program.

A better alternative would seem to reserve the relational operators for
strcmp and give string::compare(const string&) const a second optional
explicit argument with the flags to use.

Cay
horstman@cs.sjsu.edu





Author: jlp@chi.andersen.com (Larry Podmolik)
Date: 13 Jan 1994 08:20:00 -0600
Raw View
In article <1994Jan12.203343.29997@sjsumcs.sjsu.edu>, horstman@sjsumcs.sjsu.edu (Cay Horstmann) writes:
> The Borland C++ 4.0 implementation of the proposed ANSI string class
> (but not the notes that I have from the pre-San Jose distribution)
> uses static flags for
>  - paranoid check
>  - skip white space
>  - case sensitive
> to be used with string operations. For example,
>  string::set_case_sensitive(0);
>  string s, t;
>  if (s < t) // now does stricmp
> Is this part of the standard, or a Borland enhancement?

Must be Borland enhancements.  Just to be sure, I checked the most
recent draft of the library chapter to make sure, and none of this
stuff was there.

> It seems like a poor design to me. While I may agree that paranoid checking
> could be global -- you are paranoid or you are not -- skipping white space
> is clearly not, and a function that forgets to restore the white space
> flag can mess up a program.

I don't like these design decisions either.

I also question whether *any* extra features like this should be
added to a standard library class.  Shouldn't they instead derive
a new type from the standard string that adds such features?
Otherwise, someone who thinks they are writing ANSI portable code
and uses one of these extras is going to be mighty surprised
when they move their "vanilla" code to another C++ implementation!

--Larry