At 02:42 PM 12/3/2001 -0600, Andrei Zmievski wrote: >On Mon, 03 Dec 2001, Andi Gutmans wrote: > > Personally I wouldn't write code which gives FOO_BAR and Foo_BAR two > > different meanings but I think you are right that it'd be better and I > have > > an idea on how to do it which I'll lay out. > > We are only talking about global constants defined with define() as class > > constants are always case sensitive and they can distinguish what you > > mentioned above. > >That's fine for me. I want them for the keysym constants in PHP-GTK >(like GDK_KEY_A and GDK_KEY_a). For now I hack around by using >(GDK_KEY__A) for lowercase ones. Which sucks.
Oh OK. > > There's one way I can think of in order to fix define(). It has advantages > > and disadvantages. The advantage is that all constant lookups will be much > > faster than they are today (no strtolower() and no memcmp()). The > > disadvantage is that defining constants will be much slower. > > What we would do is that instead of adding the name of the constant after > > an strtolower() into the constants hash we would do the following: > > - for case-sensitive constants: Add it with the exact same case as the > > definition. > > - for case-insensitive constants: Add all possible cases for the constant. > > That means that for a word of length L we'd add at most L*2 keys to the > > hash. > > > > This solution actually would work very well. It'd would fix the above > > problem and hash lookups would be faster. It would also be a step away > from > > case-insensitive constants. It would of course make case-insensitive > > constant definitions much slower but as no C-extensions use them > > (especially after I nuke it) and only about 5 constants in Zend use > them it > > should be fine (this is assuming that not many people use the third > > argument of define() which allows them to define case-insensitive > > constants). > >What about the idea of introducing case-insensitive hashes? Modifying >hash function so that it hashes 'A' and 'a' into the same value. Because some of the keys are case-insensitive and some aren't. Case insensitive hashes don't work if you want to mix the keys. In any case, I think the solution above is a good one because there are only 5 constants in the Zend Engine which are case-insensitive. Andi -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]