texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Texmacs-dev] list.hpp "Bug?"


From: skhilji
Subject: [Texmacs-dev] list.hpp "Bug?"
Date: Wed, 07 Apr 2004 10:40:45 -0400

Among thousands of other confusing things that I find in TeXmacs, here is 
another one:

list.hpp :  The function revert()

As I am reading the code I find that list supports suppress_last() as well.

The function 'revert' comes immediately after suppress_last().

In English, the word 'revert' means to come back to a previous state.  So as I 
read the header file, I get the impression that:

suppress_last() supresses the last element in the list temporarily and revert() 
goes back to the last state---meaning it unsuppresses the last element.

But that is not true.  revert() merely reverses the list.  I think a better 
name for this function would be reverse() instead of revert().

I found out about this by writing code like this:

  typedef list<int> MyList;
  
  MyList  myl1;
  MyList  myl2;
  MyList  myl3;
  
  myl1 << 1;
  myl1 << 2;
  myl1 << 3;
  myl1 << 4;
  
  myl2 << 10;
  myl2 << 20;
  myl2 << 30;
  myl2 << 40;

  cout << myl1 << endl;
  cout << myl2 << endl;
  
  myl3 = myl1 * myl2;
  
  cout << myl3 << endl;
  
  cout << head( myl3, 3 )  << endl;
  
  cout << last_item( myl3 )  << endl;
  
  suppress_last(myl3);
  cout << myl3 << endl;
  revert(myl3);
  cout << myl3 << endl;  
  cout << revert(myl3) << endl;


This just  proves that nonstandard naming convention and non standard operator 
overloading (like using * for concatenation) only makes things harder for 
others who are used to seeing "standard" C++ code.

Salman





reply via email to

[Prev in Thread] Current Thread [Next in Thread]