Newsgroups: comp.object,comp.lang.c++,comp.lang.smalltalk,comp.lang.misc
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news4.ner.bbnplanet.net!news3.near.net!paperboy.wellfleet.com!news-feed-1.peachnet.edu!gatech!news.mathworks.com!news.ultranet.com!news.sprintlink.net!news.wwa.com!rcm!rmartin
From: rmartin@rcmcon.com (Robert Martin)
Subject: Re: Has C++ had its day?
References: <jynsyy@bmtech.demon.co.uk> <3smnlg$h6@newsbf02.news.aol.com> <id.KY2L1.Q24@nmti.com> <3sn56n$aeo@News1.mcs.com>
Organization: R. C. M. Consulting Inc. 708-918-1004
Date: Thu, 29 Jun 1995 20:16:30 GMT
Message-ID: <1995Jun29.201630.9031@rcmcon.com>
Lines: 146
Xref: glinda.oz.cs.cmu.edu comp.object:33960 comp.lang.c++:135875 comp.lang.smalltalk:25210 comp.lang.misc:22197

jim.fleming@bytes.com (Jim Fleming) writes:

>class String {
>/**
>*	String objects are used to store a collection of characters
>*	which can be accessed as an array of bytes. The size of the
>*	array can be increased or descreased as the need arises. The
>*	current count of the number of active bytes is maintained in
>*	each instance.
>*
>*	An implied null (or zero value) byte is assumed, in some cases,
>*	to follow the last active byte. This does not preclude the
>*	ability of storing a zero value byte in the string.
>*
>*/

>class inherit class AbstractArray;
>inherit AbstractArray;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

These two statements confuse me.  I assume that they mean that
String inherits from AbstractArray.  Fine.  But why two statements?

Sorry for not knowing C+@ syntax, but I'm here to learn.

If String inherits from AbstractArray, are you sure that you want that?
Are there interfaces of AbstractArray that are inappropriate for String?

>// Instance Variables

>long size; // The current size of the string including any 0 value bytes.
>char buffer[]; // The indexable instance variable that holds the bytes.

>// C+@egory: Creation

>class method (String _) new (Integer size)
>/**
>*	Create a new String object with 'size' bytes of storage.
>*		Example: a = String.new(80);
>*/
>{
>	...
>}

>class method (String _) allocate (Integer size)
>/**
>*	Create a new String object with 'size' bytes of storage.
>*		Example: a = String.allocate(80);
>*
>*/
>{
>	...
>}

What is the difference between allocate and new?  They seem to
do the same thing?


>class method (String _) {} (values[])
>/**
>*	Create a new String from the list of values.
>*		Example: a = { 'H', 'e', 'l', 'l', 'o' };
>*/
>{
>	...
>}

Is it true in C+@ that arguments do not need types?  What if the array
did not contain chars?

>// C+@egory: Accessing

>method (String _) [] (Integer index)
>/**
>*	Return the value located at the position indicated by 'index'.
>*	The first value is indexed by 0.
>*		Example: a = string[5];
>*/
>{
>	...
>}

I'd like to see the implementation of this function.  I am wondering
how the char at buffer[index] gets converted into a String.

>method (String _) []= (Integer index, Integer value)
>/**
>*	Set the value located at the position indicated by 'index'
>*	to the 'value' specified.
>*	The first value is indexed by 0.
>*		Example: string[5] = 'A';
>*/
>{
>	...
>}

I like this operator []=.  Good idea.  But why is 'value' an integer
instead of a String or a char?

>// C+@egory: Operations

>method (String _) << (String addition)
>/**
>*	ConC+@enate the additional string to a copy of the receiver
>*	and return the result.
>*
>*/
>{
>	...
>}

>// C+@egory: Version Management

>class method (_) versionId { _ = "0.0"; }

>} // String

>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

>The Interface for the above is:

>class String {

>// C+@egory: Creation
>class method (String _) new (Integer size)
>class method (String _) allocate (Integer size)
>class method (String _) {} (values[])

>// C+@egory: Accessing
>method (String _) [] (Integer index)
>method (String _) []= (Integer index, Integer value)

>// C+@egory: Operations
>method (String _) << (String addition)

>// C+@egory: Version Management
>class method (_) versionId { _ = "0.0"; }

>} // String


-- 
Robert Martin       | Design Consulting   | Training courses offered:
Object Mentor Assoc.| rmartin@oma.com     |   OOA/D, C++, Advanced OO
2080 Cranbrook Rd.  | Tel: (708) 918-1004 |   Mgt. Overview of OOT
Green Oaks IL 60048 | Fax: (708) 918-1023 | Development Contracts.
