Order of variables in "whos"

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Order of variables in "whos"

Ted.Harding
Hi All,

It seems that the order in which variables are listed by "whos" is independent
of the order in which they are created, of the alphabetical order of their
names, and of their array dimensions.

Is it random, or is there some hidden regularity?

(I ask because when there are many variables it would be nice to be able to fix
the order in which they appear, to save time in scanning the list by eye).

With thenks,
Best wishes,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <[hidden email]>
Date: 04-May-98                                       Time: 09:49:24
--------------------------------------------------------------------


Reply | Threaded
Open this post in threaded view
|

Re: Order of variables in "whos"

Frederic Gobry
Hi !

I guess the variable names are looked up through some hashing algorithm, in
order to increase the search speed. This might cause the "randomness" you've
noticed in the order in which they are listed.

Frédéric

--
    Frédéric GOBRY                  IDIAP
                               Rue du Simplon 4,
  Research Assistant          CH 1920 - Martigny
Machine Learning Group      Tel: +41 27 721 77 31


Reply | Threaded
Open this post in threaded view
|

Order of variables in "whos"

John W. Eaton-6
In reply to this post by Ted.Harding
On  4-May-1998, (Ted Harding) <[hidden email]> wrote:

| It seems that the order in which variables are listed by "whos" is
| independent of the order in which they are created, of the
| alphabetical order of their names, and of their array dimensions.
|
| Is it random, or is there some hidden regularity?

As someone said, the strange order is due to having the symbol table
information stored in a hash table.  I thought they were sorted (and I
think they were at one time) but either a change in the C++ string
class or a misunderstanding on my part broke the comparison function.
Please try the following patch.

Thanks,

jwe


Mon May  4 11:56:20 1998  John W. Eaton  <[hidden email]>

        * symtab.cc (symbol_record_info_cmp): Use string::compare instead
        of string::operator==.


*** src/symtab.cc~ Tue Apr  7 15:40:17 1998
--- src/symtab.cc Mon May  4 11:56:44 1998
***************
*** 1018,1024 ****
  static inline int
  symbol_record_info_cmp (symbol_record_info *a, symbol_record_info *b)
  {
!   return (a->name () == b->name ());
  }
 
  static int
--- 1018,1026 ----
  static inline int
  symbol_record_info_cmp (symbol_record_info *a, symbol_record_info *b)
  {
!   string a_nm = a->name ();
!   string b_nm = b->name ();
!   return a_nm.compare (b_nm);
  }
 
  static int


Reply | Threaded
Open this post in threaded view
|

RE: Order of variables in "whos"

Ted.Harding
On 04-May-98 John W. Eaton wrote:
> As someone said, the strange order is due to having the symbol table
> information stored in a hash table.  I thought they were sorted (and I
> think they were at one time) but either a change in the C++ string
> class or a misunderstanding on my part broke the comparison function.
> Please try the following patch.

Thanks for the info, and the tip.

Yes, in 1.1.1 "whos" lists them in ASCII sort order!

Best wishes,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <[hidden email]>
Date: 04-May-98                                       Time: 23:11:31
--------------------------------------------------------------------