Thursday, August 21, 2008

Lessons Learned part 1.

I thought I would share some lessons learned while coding freemat. The first lesson is due to Samit.
`#include class A { int m_data;public: A(int m) : m_data(m) {std::cout << "Construct A: " << m_data << "\n";} const int & value() const { return m_data;} const A doubled() const {return A(2*m_data);} ~A() {std::cout << "Destruct A: " << m_data << "\n";}};int main() { A x(5); const int &y(x.doubled().doubled().value()); std::cout << "y = " << y << "\n"; return 0;}The result:\$ ./tempConstruct A: 5Construct A: 10Construct A: 20Destruct A: 20Destruct A: 10y = 20Destruct A: 5Note that the temporary object "A" is destructed _before_ the constref to it's internals is used. So...int main() { A x(5); const A &t(x.doubled().doubled()); const int &y(t.value()); std::cout << "y = " << y << "\n"; return 0;}yields:\$ g++ -o temp temp.cpp\$ ./tempConstruct A: 5Construct A: 10Construct A: 20Destruct A: 10y = 20Destruct A: 20Destruct A: 5Yikes.`

Saturday, August 9, 2008

Progress update

Eugene's list:
(Done) 1. Finish "patch" command implementation.
(Done) 2. Implement "hist".
3. Try porting statistics and imaging toolbox from octave-forge (by request).
(Half-way done) 4. Re-enable OpenGL rendering. Add command to switch between Qt and OpenGL rendering. Debug an issue that was reported earlier - slowdown with OpenGL rendering.
5. Look at upgrading to LLVM 2.3 (or 2.4 if it is released by then.)

Samit is also making good progress on the new array class, and new type system implementation. He says that many of the unit test pass.