How to emulate Objective C with Records? lazarus / 62-General ---------------------------------------------------------------------- JiaXing · 2020-05-04 12:21 OK. I will try with an easier approach to emulate OOP in procedure mode Pascal. Anyway, it's just for fun ---------------------------------------------------------------------- flowCRANE · 2020-05-04 13:32 What do you want to achive? Some sort of inheritance in combination with regular records? ---------------------------------------------------------------------- JiaXing · 2020-05-04 15:09 Quote from: furious programming on May 04, 2020, 03:32:01 pmWhat do you want to achive? Some sort of inheritance in combination with regular records? Objective C like OOP emulation on Pascal but with advanced records, though, not normal records. ---------------------------------------------------------------------- Thaddy · 2020-05-04 15:10 {$mode macpas} and maybe {$modeswitch advancedrecords} too? ---------------------------------------------------------------------- JiaXing · 2020-05-04 15:14 Quote from: Thaddy on May 04, 2020, 05:10:32 pm{$mode macpas}{$modeswitch advancedrecords} maybe? Macpas mode is objective pascal. OK I will try. But all of this is just for fun, though. If I'm not report back that because I have found something more fun to do  BTW, I want to know more about this Macpas mode. Information on the wiki (https://wiki.freepascal.org/Mode_MacPas) is too much for me. Some kind of short summary should be good. ---------------------------------------------------------------------- Jonas Maebe · 2020-05-04 16:51 Mode MacPas is for emulating the Pascal compilers that originated on Classic MacOS (MacOS 9 and below). It has nothing to do with Objective-C. FPC has a modeswitch to enable interfacing with and writing new Objective-C-compatible code, called Objective-Pascal. It is documented: https://www.freepascal.org/docs- html/current/ref/refch11.html FPC also comes with several interface units for the Cocoa framework, but these are not documented since they are literal API translations. You'll have to browse the source code (in packages/cocoaint/src) to see which classes/frameworks have headers (or just try to include a unit with the name of a particular framework; if it compiles, it has been translated). ---------------------------------------------------------------------- JiaXing · 2020-05-04 17:19 Quote from: Jonas Maebe on May 04, 2020, 06:51:26 pmMode MacPas is for emulating the Pascal compilers that originated on Classic MacOS (MacOS 9 and below). It has nothing to do with Objective-C. FPC has a modeswitch to enable interfacing with and writing new Objective-C-compatible code, called Objective-Pascal. It is documented: https://www.freepascal.org/docs- html/current/ref/refch11.html FPC also comes with several interface units for the Cocoa framework, but these are not documented since they are literal API translations. You'll have to browse the source code (in packages/cocoaint/src) to see which classes/frameworks have headers (or just try to include a unit with the name of a particular framework; if it compiles, it has been translated). Thank you. Do you know if Objective-Pascal could interface with Objective-C code on Linux? There is GNUStep and libobjc2 on Linux, too. ---------------------------------------------------------------------- JiaXing · 2020-05-04 17:22 Quote from: Thaddy on May 04, 2020, 05:10:32 pm{$mode macpas} and maybe {$modeswitch advancedrecords} too? Nope. Mode macpas has nothing to do with Objective-C style OOP. I didn't found any example for advanced records, though. So I don't know if I just declare the function inside the records and implement it elsewhere or implement it directly inside the record. Trial and error this time too time consuming. I have not yet got my code to compile. ---------------------------------------------------------------------- Jonas Maebe · 2020-05-04 17:30 Quote from: JiaXing on May 04, 2020, 07:19:12 pmThank you. Do you know if Objective-Pascal could interface with Objective-C code on Linux? There is GNUStep and libobjc2 on Linux, too. There is no support yet for this in the compiler, but someone interested in such functionality and knowledge about the GNUStep Objective-C runtime could probably add it without too much trouble.