Thread overview
the switch statement with reference to strings and case sensitivity
Aug 17, 2001
Scott Robinson
Aug 17, 2001
Russ Lewis
Aug 17, 2001
Scott Robinson
Aug 17, 2001
Russ Lewis
Aug 17, 2001
Dave Nebinger
Aug 18, 2001
Walter
August 17, 2001
The inclusion of strings (ex: "switch (s) { case "hello": case "HELLO": }")
I believe is a great addition.

However, that said, you haven't specified if the string matching is case sensitive. Reason suggests it is, and this doesn't make the new switch statement ability as useful as it could be.

I wonder if there could be a possible inclusion of of something like switch
(s) with (y), in that y is/can be strcmp or stricmp?

The dealings of return values, loops, and sensitivity to the case contents are all issues which can be worked out simply - but specific implementatoin I leave to the actual designers.

Scott.

-- 
jabber:quad@jabber.org         - Universal ID (www.jabber.org) http://dsn.itgo.com/           - Personal webpage robhome.dyndns.org             - Home firewall

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GAT dpu s: a--- C++ UL+++ P++ L+++ E- W++ N+ o+ K w
O M V- PS+ PE Y+ PGP+++ t++ 5 X R tv b++++ DI++++ D++
G+ e+ h! r- y
------END GEEK CODE BLOCK------
August 17, 2001
Scott Robinson wrote:

> The inclusion of strings (ex: "switch (s) { case "hello": case "HELLO": }")
> I believe is a great addition.
>
> However, that said, you haven't specified if the string matching is case sensitive. Reason suggests it is, and this doesn't make the new switch statement ability as useful as it could be.
>
> I wonder if there could be a possible inclusion of of something like switch
> (s) with (y), in that y is/can be strcmp or stricmp?

Or, perhaps, regular expressions could be used. :)

August 17, 2001
Yikes! Are regular expressions, by default, in the language?

Regular expressions certainly seem to defeat the idea of a readable language. ;-) Plus they're a bit heavy weight for a couple case insensitive string comparisons.

Scott.

In article <3B7D3B11.47C93DE@deming-os.org>, Russ Lewis wrote:
>Scott Robinson wrote:
>
>> The inclusion of strings (ex: "switch (s) { case "hello": case "HELLO": }")
>> I believe is a great addition.
>>
>> However, that said, you haven't specified if the string matching is case sensitive. Reason suggests it is, and this doesn't make the new switch statement ability as useful as it could be.
>>
>> I wonder if there could be a possible inclusion of of something like switch
>> (s) with (y), in that y is/can be strcmp or stricmp?
>
>Or, perhaps, regular expressions could be used. :)
>


-- 
jabber:quad@jabber.org         - Universal ID (www.jabber.org) http://dsn.itgo.com/           - Personal webpage robhome.dyndns.org             - Home firewall

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GAT dpu s: a--- C++ UL+++ P++ L+++ E- W++ N+ o+ K w
O M V- PS+ PE Y+ PGP+++ t++ 5 X R tv b++++ DI++++ D++
G+ e+ h! r- y
------END GEEK CODE BLOCK------
August 17, 2001
Scott Robinson wrote:

> Yikes! Are regular expressions, by default, in the language?
>
> Regular expressions certainly seem to defeat the idea of a readable language. ;-) Plus they're a bit heavy weight for a couple case insensitive string comparisons.

Yeah, they're pretty heavyweight for simple compares, but they allow unbelievable flexibility.  Perhaps something analogous to grep, where you can do "simple" compares with a trivial syntax, and regular expressions if necessary.

August 17, 2001
Guys, what's wrong with "switch (lower(s)){case 'hello':..."?

"Russ Lewis" <russ@deming-os.org> wrote in message news:3B7D4064.66FF69BC@deming-os.org...
> Scott Robinson wrote:
>
> > Yikes! Are regular expressions, by default, in the language?
> >
> > Regular expressions certainly seem to defeat the idea of a readable language. ;-) Plus they're a bit heavy weight for a couple case
insensitive
> > string comparisons.
>
> Yeah, they're pretty heavyweight for simple compares, but they allow
unbelievable
> flexibility.  Perhaps something analogous to grep, where you can do
"simple"
> compares with a trivial syntax, and regular expressions if necessary.
>


August 18, 2001
Scott Robinson wrote:

> The inclusion of strings (ex: "switch (s) { case "hello": case "HELLO": }")
> I believe is a great addition.

I am a bit puzzled by how this would be implemented.

Case 1: strings are simiilar in internal structure to C strings (a pointer to bytes, possibly with a length). Then, are two strings with the same content but different values equal in a switch?

Note that you can't easily guarantee that the pointers for identical strings will always be equal, at least in the case of shared libraries...


Case 2: strings are more complex things (like a string token, an ID in a string table, an atom, call it what you want). In that case, identity is easier to define, BUT you pay a price on every string creation.


Christophe
PS: Maybe this is somehwere in the spec, but I did not see it.


August 18, 2001
Yes, it's case sensitive. -Walter

Scott Robinson wrote in message ...
>The inclusion of strings (ex: "switch (s) { case "hello": case "HELLO": }")
>I believe is a great addition.
>
>However, that said, you haven't specified if the string matching is case sensitive. Reason suggests it is, and this doesn't make the new switch statement ability as useful as it could be.
>
>I wonder if there could be a possible inclusion of of something like switch
>(s) with (y), in that y is/can be strcmp or stricmp?
>
>The dealings of return values, loops, and sensitivity to the case contents are all issues which can be worked out simply - but specific implementatoin I leave to the actual designers.
>
>Scott.
>
>--
>jabber:quad@jabber.org         - Universal ID (www.jabber.org) http://dsn.itgo.com/           - Personal webpage robhome.dyndns.org             - Home firewall
>
>-----BEGIN GEEK CODE BLOCK-----
>Version: 3.12
>GAT dpu s: a--- C++ UL+++ P++ L+++ E- W++ N+ o+ K w
>O M V- PS+ PE Y+ PGP+++ t++ 5 X R tv b++++ DI++++ D++
>G+ e+ h! r- y
>------END GEEK CODE BLOCK------