On Thu, Mar 26, 2009 at 11:06:03AM +0000, Martin Friebe wrote: > Marco van de Voort 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. > 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?
Exactly. Also the alternative presented wasn't if then nesting, but rather a library routine that is like a POS for array of string. > 2) Optimizations: > If string-case existed, the compiler could optimize the code, by using > hashes or tree like lookup. This can be done better by the library procedure, since that is more easily changable than language. Including hash algorithm etc. > 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 doubt this is so good for the beginner. Nearly no tokenizer works this way. > I think if you have large enough string casings and need the speed, you > sghould use the tools specially made for this. If the need was really this high, probably lazarus already would have a lexer/yacc like app internal, and you could edit grammars in a comfortable editor, with diagramming and consistency checking support. It is so horrible little subset of a parser, it is next to useless, except for the last poor guy coming from basic that wants to "streamline/modernize" his nested if..then's without really thinking about the problem. _______________________________________________ Lazarus mailing list [email protected] http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
