gnucap-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnucap-devel] parameter case sensitivity


From: al davis
Subject: Re: [Gnucap-devel] parameter case sensitivity
Date: Sun, 6 Nov 2016 12:55:02 -0500

On Sat, 5 Nov 2016 14:48:42 +0100
Felix Salfelder <address@hidden> wrote:
> unlike an (existing) FAT, our maps could follow our own rules.

FAT is a hybrid.  Everything (almost) is converted to UPPER.

The existing hybrid in gnucap is similar, except that it is lower.

> 
> if we sort strings like this (alphabetic order over case)
> Aa
> aa
> AB <=1
> aB <=2
> Ba
> ba
> BB
> bB
> instead of by ascii value
> AB  <=1
> Aa
> BB
> Ba
> aB  <=2
> aa
> bB
> ba
> then, case insensitive bisection search works, as equal words are stored
> close to each other.

I was thinking the same.
> 
> i have implemented this as a specialized std::map with a custom less
> implementation. will try to get this under u_parameter.h...
> 

Gnucap's case-sensitivity code is already more complex than it should
be, and needs to be simplified.  Most places where it shows, it
shouldn't.  One goal should be that case-sensitivity stuff should be
confined to the character compare function, and not be seen anywhere
else.  (except, obviously, where you are specifying it.)

I am thinking a new kind of character .. call it "Ichar".  It's just
like a "char" except for the compare functions.

// just sorting as above
bool less(a,b){
        return (tolower(a)==tolower(b)) ? a<b : tolower(a)<tolower(b);
}

// with a case-sensitivity switch
bool less(a,b){
        return (!OPT::case_insensitive && tolower(a)==tolower(b))
                ? a<b : tolower(a)<tolower(b); }

Now use it everywhere.

Then .. 

Recall .. std::string is a typedef for std::basic_string<char>

So we would have: typedef std::basic_string<Ichar> IString

.. and go from there.



Once that is done, all those "if (insensitive)" can be stripped.


We need to think of "what-if's" regarding switching modes, to make sure
it makes sense.

The issues:

1. Parameter is defined case-sensitive, then used insensitive.
        This one seems easy at first, but what about duplicates?

2. Parameter is defined insensitive, then used sensitive.
        Does storage preserve case?
        Does it become sensitive after initial storage?
        or does this word become insensitive forever?

3. Remember, it's not just parameters.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]