RE:cint & dereferencing

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Tue Jun 08 1999 - 12:03:44 MEST


Dear Joerg,

Thank you for your message. There are 2 things.

1) CINT extension,
 Many of CINT users previously used Fortran or BASIC in scientific computation
.
 Cint extends some capability, such as '**' power operator, for convenience.
 This creates conflict to string C++ definition. 

2) Cint accepts most of K&R and ANSI C/C++ language construct but not perfect.
 In fact, Cint is not aimed to be a 100% ANSI/ISO compliant C/C++ language
 processor. It rather is a portable script language environment. 
 "Compiler works but cint doesn't" is not always a good enough reason
 especially when there is simpler alternative.

   cout <<y **(x+0)<<endl; // evil

 This is legal C++ code which means  "y * (*(x+0))"
 This case, in particular, does not work on cint because of special '**'
 operator support. I believe many people misunderstand above expression or 
 even do not have any idea what is going on. There is simple and straight 
 forward alternative.

   cout << y*x[0] << endl;

 This is simpler, understandable and works on cint.

  cout << y * (*(x+0)) << endl;

 This also works, but I do not recommend this in terms of C++ coding style
 concern. 

 But, I may possibly misunderstand. If there is convincing reason of 
 put more attention on expression like this, please let me know. 

Thank you
Masaharu Goto



------------------------------------------------------------------
hi all,

  i can't imagine this was not under discussion before. but anyhow:
  the (legal) code

  {
    Float_t x[1]={42};
    Float_t y=666;
    cout <<y **(x+0)<<endl; // evil
  }

  does not execute in root (2.21.08, linux-glibc).
  the expression *(x+0) is evaluated to infty
  (an additional pair of par's around it solves the problem).

  as c++ does not know ** as pow(), the expression is
  unambiguous even without the maximum-much-principle...

  cu,

j"org.



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:34 MET