Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!asuvax!mcdphx!dover!digital!norm!shelley From: shelley@atc.sps.mot.com (Norman K. Shelley) Newsgroups: comp.lang.eiffel Subject: class STRING model needs fixing Message-ID: <48a5572e.12c9a@digital.sps.mot.com> Date: 14 Feb 90 21:59:01 GMT Sender: news@digital.sps.mot.com Lines: 56 New Desired Upgrade for Eiffel 3.0 (14Feb90) Currently Using; Eiffel 2.2B Class upgrade: STRING Problem Statement: 1.) The current Eiffel model of the class "STRING" is based on the C model of strings found in the C subroutine library. The model requires an allocation of one more byte than the number of characters in a string and this byte is the last byte in a string and it is NULL signifing the end of the string. String lengths are dynamically computed and there is no idea of saving/updating this state. 2.) Eiffel needs a better model that reflects the unique features Eiffel offers without sacrificing execution speed. Assertions heavily rely on checking the length of the string. This is a function and not an attribute thereby demanding much more CPU resources then should be required. Givens: 1.) The feature "count" of class "STRING" is an Eiffel function that calls the C function "strlen". When "strlen" is called it takes the input pointer and starts a count of the number of characters pointed to by the input pointer. It stops the count when it finds a NULL character. Therefore this function is expensive in time. This can become compounded when it is called repeatedly or for long strings. 2.) The class "STRING" uses the function "count" in MANY of its assertions therefore increasing the number of calls to this expensive function. 3.) Not counting uses of the function "count" in assertions it is called in seven different places (mainly from append, prepend, extend, and precede) Desired Features: 1.) Until a more suitable model is found and implemented the function "count" should be implemented as an attribute. Problems in modifing class STRING: 1.) Only an I.S.E. employee can change I.S.E.'s compiler and the compiler treats class "STRING" specially e.g. a constant STRING never calls the normal STRING create therefore the count field can not be set for STRING constants. 2.) Other C calls like "rm_all" change the string with no concept of updating a dynamic count field. Norman Shelley Motorola - ATC 2200 W. Broadway AZ09/M350 Mesa, AZ 85202 ...!uunet!dover!atc!shelley shelley@atc.sps.mot.com (602) 962-2473