You aren't seeing a difference because you're using the same set of
objects.  for your indexes.  Here is a simple example that will show the
difference.

i1 = "abc"
i2 = "ab"||"c"

table = .table~new
itable = .identitytable~new

table[i1] = "Walter"
table[i2] = "Pachl"

say table~items   -- 1 item
say table[i1] table[i2] -- "Pachl Pachl"

itable[i1] = "Walter"
itable[i2] = "Pachl"

say itable~items   -- 2 items
say itable[i1] itable[i2] -- "Walter Pachl"

With a table, both i1 and i2 are the same index because the two objects
compare equal.  With an identitytable, i1 and i2 are NOT the same index
because they are different objects.  For most purposes, a table is
sufficient for the job.  There are some advanced uses, however, where the
distinction is important.  You really need to have a better understanding
of what objects are before I attempt to explain those uses.

Rick


On Fri, Sep 21, 2012 at 2:10 PM, Walter Pachl
<christel.u.w.pa...@chello.at>wrote:

> Can someone tell me why I cannot find a difference?
> I read and compared carefully sections 5.3.16 and 17.
> Pls find my observations (and change suggestions) at the end ot this.
> Would it be better to report that as a doc bug (?)
>
> Thanks for your understanding
> Walter
>
>
>
> /* REXX ***************************************************************
> * Trying to demonstrate the difference between table and identitytable
> * 21.09.2012 Walter Pachl
> **********************************************************************/
> Select
>   When arg(1)='?' Then Do
>     Say 'rexx testtab <I> tests table vs. identitytable'
>     Say 'What must be changed to see a difference?'
>     Say 'I expected the indexes c and cc to make a difference'
>     Say 'what''s the difference between == and object identity??'
>     Exit
>     End
>   When arg(1)='I' Then Do
>     Say 'Test with identitytable'
>     tab=.identitytable~new /* create a new identity                 */
>     End
>   Otherwise Do
>     Say 'Test with identitytable'
>     tab=.table~new    /* create a new table                          */
>     End
>   End
> Call create_objects
> tab[1]=a              /* fill first table entry                      */
> tab["two"]=b          /* index can be any object                     */
> tab~put(e,c)          /* put method is synonymous with []=           */
> cc=c~copy
> Say 'c: '  c~identityHash
> Say 'cc:' cc~identityHash
> tab[four]=d           /* four = FOUR                                 */
> Call show_tab 1
> tab~put(e,cc)         /* put method is synonymous with []=           */
> If cc==c  Then Say 'cc and c are =='
> If cc\==c Then Say 'cc and c are \=='
> Call show_tab 2
> Exit
>
> show_tab:
>   Say 'show_tab' arg(1)
>   Say tab~items 'items'
>   xlist=tab~allindexes  /* puts all indexes into array xlist         */
>   Do item over xlist    /* loop over array and show elements         */
>     Say item            /* -> 1                                      */
>     End
>   ilist=tab~allitems    /* puts all items into array ilist           */
>   i=0
>   Do item over ilist    /* loop over array and show elements         */
>     Say item~show       /* ->     1 Adam Ants       1000             */
>     End
>   Return
>
> create_objects:       /* ->                                          */
> a=.payroll~new(1,'Adam Ants',1000) /* create a payroll entry         */
> b=.payroll~new(2,'Barry Bee',2000) /* create a payroll entry         */
> c=.payroll~new(3,'Charly Ce',3000) /* create a payroll entry         */
> d=.payroll~new(4,'Donald Duck',4000) /* create a payroll entry       */
> e=.payroll~new(5,'Eva Ericson',5000) /* create a payroll entry       */
> f=.payroll~new(6,'Fred Feuerstein',6000) /* create a payroll entry       */
> Return
> ::class payroll public
> ::attribute persnr                 /* variables of payroll's objects */
> ::attribute name
> ::attribute salary
> ::method init                      /* initialize the object          */
>   expose persnr name salary        /* get access to payroll's objects*/
>   parse arg persnr, name, salary   /* assign parameters to variables */
> ::method show                      /* show the payroll data          */
>   expose persnr name salary
>   Return right(persnr,5) left(name,15) salary
>
> rexxref.pdf observations (Output of my 'famous' COMPAT program
> (after massaging the texts)
>
> table.txt
> identitytable.txt
>
>
>  OLD-> 5.3.16. The Table Class
>  OLD-> A table is a collection with indexes that can be any object.
>  OLD-> In a table, each item is associated with a single index,
>  OLD-> and there can be only one item for each index
>  OLD-> (unlike a relation, which can contain more than one item with the
> same index).
>  OLD-> Index equality is determined by using the == method.
>            add ... and item equality ???
>  OLD-> Note: The Table class also has available class methods that its
> metaclass,
>
>  NEW-> 5.3.17. The IdentityTable Class
>  NEW-> An identity table is a collection with indexes that can be any
> object.
>  NEW-> In an identity table, each item is associated with a single index,
>  NEW-> and there can be only one item for each index.
>  NEW-> Index and item matches in an identity table are made using an
> object identity comparison.
>  NEW-> That is, an index will only match if the same instance is used in
> the collection.
>  NEW-> Note: The IdentityTable class also has available class methods that
> its metaclass,
>
>        the Class class, defines. It also inherits methods from the Map
> Collection class.
>        5.3.16.1. Inherited Methods
>        Methods inherited from the Object class.
>        new (class method) instanceMethod send
>        = \= == \== <> >< instanceMethods sendWith
>        class isA setMethod
>        copy isInstanceOf start
>        defaultName objectName startWith
>        hasMethod objectName= string
>        identityHash Request unsetMethod
>        init Run
>        Methods inherited from the Collection class.
>        [] hasIndex put
>        []= hasItem subset
>        allIndexes index supplier
>        allItems intersection union
>        at items xor
>        difference makeArray
>        Methods inherited from the MapCollection class.
>        putAll
>        5.3.16.2. new (Class Method)
>        >>-new---------------------------------------------------------><
>
>  OLD-> Returns an empty Table object.
>  NEW-> Returns an empty IdentityTable object.
>
>        5.3.16.3. []
>        >>-[index]-----------------------------------------------------><
>        Returns the item associated with index. This is the same as the
> at() method.
>        5.3.16.4. []=
>        >>-[index]=item------------------------------------------------><
>        Adds item to the table at index index. This method is the same as
> the put() method.
>        5.3.16.5. allIndexes
>        >>-allIndexes--------------------------------------------------><
>
>  OLD-> Returns an array of all indexes contained in the table.
>  NEW-> Returns an array of all indices contained in the table.
>                                ???????
>        5.3.16.6. allItems
>
>        >>-allItems----------------------------------------------------><
>        Returns an array of all items contained in the table.
>        5.3.16.7. at
>        >>-at(index)---------------------------------------------------><
>        Returns the item associated with index index.
>        Returns the Nil object if the collection has no item associated
> with index.
>        5.3.16.8. empty
>        >>-empty-------------------------------------------------------><
>        Removes all items from the table.
>        5.3.16.9. hasIndex
>        >>-hasIndex(index)---------------------------------------------><
>        Returns 1 (true) if the collection contains any item associated
> with index index, or 0 (false).
>        5.3.16.10. hasItem
>
>  OLD-> >>-hasItem(value)----------------------------------------------><
>  OLD-> Returns 1 (true) if the collection contains the value at any index
> position
>
>  NEW-> >>-hasItem(item)-----------------------------------------------><
>  NEW-> Returns 1 (true) if the collection contains the item at any index
> position
>
>             why different (item vs. value)???
>
>        or otherwise returns 0 (false).
>
>  DEL-> Item equality is determined by using the == method of item.
>
>        5.3.16.11. index
>        >>-index(item)-------------------------------------------------><
>        Returns the index of the specified item within the table.
>        If the target item appears at more than one index, the first
> located index will be returned.
>        Returns the Nil object if the table does not contain the specified
> item.
>
>  DEL-> Item equality is determined by using the == method of item.
>
>        5.3.16.12. isEmpty
>        >>-isEmpty-----------------------------------------------------><
>        Returns 1 (true) if the table is empty. Returns 0 (false) otherwise.
>        5.3.16.13. items
>        >>-items-------------------------------------------------------><
>        Returns the number of items in the collection.
>        5.3.16.14. makeArray
>        >>-makeArray---------------------------------------------------><
>        Returns a single-index array containing the index objects.
>        The array indexes range from 1 to the number of items.
>        The collection items appear in the array in an unspecified order.
>        5.3.16.15. put
>        >>-put(item,index)---------------------------------------------><
>        Makes the object item a member item of the collection and
> associates it with index index.
>        The new item replaces any existing items associated with index
> index.
>        5.3.16.16. remove
>        >>-remove(index)-----------------------------------------------><
>
>  OLD-> Returns and removes the table item with index index.
>  NEW-> Returns and removes from a collection the member item with index
> index.
>
>                                 ???????????? the identitytable
>
>        Returns the Nil object if no item has index index.
>
>        5.3.16.17. removeItem
>        >>-removeItem(item)--------------------------------------------><
>        Removes an item from the table. If the target item exists at more
> than one index,
>        the first located item is removed. The return value is the removed
> item.
>
>  DEL-> Item equality is determined by using the == method of item.
>
>        5.3.16.18. supplier
>        >>-supplier----------------------------------------------------><
>        Returns a Supplier object for the collection.
>        The supplier allows you iterate over the index/item pairs
>        contained in the table at the time the supplier was created.
>        The supplier iterates over the items in an unspecified order.
> -----------------------
>      3 Deletions
>     12 Changes
>      0 Insertions
>     78 unchanged lines.
> -----------------------
>
>
>
> ------------------------------------------------------------------------------
> Got visibility?
> Most devs has no idea what their production app looks like.
> Find out how fast your code is with AppDynamics Lite.
> http://ad.doubleclick.net/clk;262219671;13503038;y?
> http://info.appdynamics.com/FreeJavaPerformanceDownload.html
> _______________________________________________
> Oorexx-devel mailing list
> Oorexx-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>
------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to