unknown macro syntax lazarus / 62-General ---------------------------------------------------------------------- Nitorami · 2018-06-27 16:29 I am just re-writing a part of Stefan Ziegenbalgs pascal units for matrix operations found on the contributions page. The unit is quite old, 1999-2002, and uses a lot of macros which do not compile. Does anyone understand this syntax ? Is it from a different compiler possibly, or has this been a valid fpc syntax 16 years ago ? It reads like Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i //define[@c omp(][,#1,#2)][#0.pt[(#2)*#0.x+#1]]//ifdef[complex]//define[@rcomp(][, #1,#2)][#0.pt[(#2)*#0.x+#1].r]//define[@icomp(][,#1,#2)][#0.pt[(#2)*#0 .x+#1].r]//else//define[@rcomp(][,#1,#2)][#0.pt[(#2)*#0.x+#1]]//endif  //define[@decref(][)][if (#0.id>0) and (#0.id<=MaxMatrix) and (matlist[#0.id].ref>0) then dec(matlist[#0.id].ref)]//define[@incref(][)][if (#0.id>0) and (#0.id<=MaxMatrix) then inc(matlist[#0.id].ref)] //define[@owalert(][,#1,#2)][if (#0.id=#1.id) and ((#0.x<>#1.x) or (#0.y<>#1.y) or (#0.pt<>#1.pt)) then faterror('#2: corrupt parameters')] ---------------------------------------------------------------------- marcov · 2018-06-27 16:47 Different compiler or separate preprocessor. Nothing like this was ever in FPC itself ---------------------------------------------------------------------- Thaddy · 2018-06-27 17:30 Quote from: marcov on June 27, 2018, 06:47:18 pmDifferent compiler or separate preprocessor. Nothing like this was ever in FPC itself Nope indeed. There once was a clear statement that parameterised macro's would not be introduced any time soon. (I have still mixed opinions about that, but otherwise you have the C trap, so I see the point). Anyway, usually h2pas gives you some pointers on how to solve it and a function body for such macro's. ---------------------------------------------------------------------- marcov · 2018-06-27 19:11 Quote from: Thaddy on June 27, 2018, 07:30:45 pmQuote from: marcov on June 27, 2018, 06:47:18 pmDifferent compiler or separate preprocessor. Nothing like this was ever in FPC itself Nope indeed. There once was a clear statement that parameterised macro's would not be introduced any time soon. (I have still mixed opinions about that, but otherwise you have the C trap, so I see the point). I fully agree. It just leads the discussion to the next "feature" of C macros, and a new load of newbies will swear upon their life that they couldn't program without it. ---------------------------------------------------------------------- Thaddy · 2018-06-27 19:57 Quote from: marcov on June 27, 2018, 09:11:13 pmI fully agree. It just leads the discussion to the next "feature" of C macros, and a new load of newbies will swear upon their life that they couldn't program without it. Unless you want Object Pascal ++, after all C++ is one *huge* set of macro's on top of C... Or about that... ---------------------------------------------------------------------- Nitorami · 2018-06-27 20:25 I agree with Thaddy's "mixed feelings" -  the macros samples here looks like rather a mess but I understand why the author used them. His matrix is a simple record Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type TMatrix=record       columns, rows     : longint;  { columns, rows }     ref,sr  : longint;  { reference counts }       data      : ^float;       end;  and he needed a simple way to access the elements M[i,j], avoiding cumbersome constructs such as M.data[M.columns*i+j]. If we cannot use getters/setters because they are too slow, neither want to do pointer arithmetics, parameterised macros may not be the worst of all solutions. ---------------------------------------------------------------------- marcov · 2018-06-28 06:46 Quote from: Thaddy on June 27, 2018, 09:57:29 pmUnless you want Object Pascal ++, after all C++ is one *huge* set of macro's on top of C... Or about that... C++ isn't. The early nineties C++ reference compiler was, but that is an implementation, not a design characteristic. Generics/templates were very new back then, and its implementation is non trivial. In that sense FPC/Delphi were lucky to be able to see how it is done with other languages. ---------------------------------------------------------------------- PascalDragon · 2018-06-28 20:23 Quote from: Thaddy on June 27, 2018, 09:57:29 pmQuote from: marcov on June 27, 2018, 09:11:13 pmI fully agree. It just leads the discussion to the next "feature" of C macros, and a new load of newbies will swear upon their life that they couldn't program without it. Unless you want Object Pascal ++, after all C++ is one *huge* set of macro's on top of C... Or about that... I can't agree here considering I earn my money working with C++ code and thus work with much C++ code. C++ is vastly more type safe (and strict) than C and templates allow for much type safety and meta programming (though of course most of the latter is needed due to C++ not having an as rich RTTI as Object Pascal has  ). ---------------------------------------------------------------------- Thaddy · 2018-06-28 20:40 I was just fishing and Marco took the bite..(we are really old school).