Extend Your Language January 31, 2008Posted by gordonwatts in computers.
A few days ago I had a post about extending objects – the desire to add little utility methods to objects that others had defined (and control). A few of the comments triggered something way back in the back of my head.
We (particle physics) have solved this sort of problem already. Anyone remember FLECS or RATFOR (holy cow, look at the original authors of RATFOR)? (there are others). I personally used FLECS when I was on the AMY experiment. We wanted some C-like structures in our FORTRAN so we used FLECS to add them — curly brackets, etc. The FLECS preprocessor was an extra step in the compilation process – it produced F77 code that was fed to the real compiler.
I’ve seen almost nothing like that for C++. Certainly, it is a much more complex language, so it is much harder to extend in this way, but it must be possible. Are there such languages? Any extension methods there?🙂
P. Canal, a ROOT developer, pointed out to me that CINT supports extension methods in much the same way that python does – you can just add methods to your objects. Of course, in the case of CINT, this requires you to have the class loaded into CINT and you have to call it through CINT.