[Lazarus] Easiest way to "case" strings

Martin Friebe lazarus at mfriebe.de
Thu Mar 26 12:06:03 CET 2009


Marco van de Voort wrote:
> On Thu, Mar 26, 2009 at 10:28:50AM +1000, Alexander Klenin wrote:
>   
>> Since string was introduced as built-in "scalar" type with defined
>> equality, lack of 'case' support can be viewed as a design bug.
>>     
>
> I don't see string as a scalar type. It is an array or complex type IMHO.
>
>   
True,...

anyway, best argument(s) I think I saw for string case so far:

1) Readability.
I think it is true, 10 or more lines of  IF...ELSE IF ... can obscure 
readability.

I wonder how many of the cases where this happens, actually are truly 
needed?
How many of them could have used a simpler data-type, and how many of 
them would have wanted are more specialized approach such as LEX?


2) Optimizations:
If string-case existed, the compiler could optimize the code, by using 
hashes or tree like lookup.

While that's true, I wonder if that is really a good  idea. It would be 
the first step of embedding LEX/YACC into the language.
One may say this is of benefits for beginners, because the need to learn 
less about other tools; the truth is, discouraging a beginner from 
learning has no long time benefit.

I think if you have large enough string casings and need the speed, you 
sghould use the tools specially made for this.


Just some thoughts from me / Regards
Martin



More information about the Lazarus mailing list