pascal vs object pascal vs the rest? Want to make pascal bindings for godot. lazarus / 21-General ---------------------------------------------------------------------- etet · 2021-02-06 22:19 What exactly is the difference between "regular pascal" and the extended version known as object pascal? I want to make a pascal bindings for gdntative in godot, the video game engine, but have no idea which pascal dialect I should target. Should I target GNU pascal? Object pascal? Regular pascal? free pascal? Is there a subset of pascal that can target all dialects? ---------------------------------------------------------------------- marcov · 2021-02-06 22:41 Quote from: etet on February 06, 2021, 11:19:18 pmWhat exactly is the difference between "regular pascal" and the extended version known as object pascal? Large.  Like C vs C++. Quote I want to make a pascal bindings for gdntative in godot, the video game engine, but have no idea which pascal dialect I should target. Should I target GNU pascal? Object pascal? Regular pascal? free pascal? Is there a subset of pascal that can target all dialects? Depends on if you want to make object oriented or straight procedural bindings. In either case, since this is a Free Pascal/Lazarus forum, my reliable advise is to use Free Pascal/Lazarus. ---------------------------------------------------------------------- etet · 2021-02-06 22:48 Quote from: marcov on February 06, 2021, 11:41:10 pmQuote from: etet on February 06, 2021, 11:19:18 pmWhat exactly is the difference between "regular pascal" and the extended version known as object pascal? Large.  Like C vs C++. Quote I want to make a pascal bindings for gdntative in godot, the video game engine, but have no idea which pascal dialect I should target. Should I target GNU pascal? Object pascal? Regular pascal? free pascal? Is there a subset of pascal that can target all dialects? Depends on if you want to make object oriented or straight procedural bindings. In either case, since this is a Free Pascal/Lazarus forum, my reliable advise is to use Free Pascal/Lazarus. Can't I support both OOP and straight procedural bindings? I've read books dating back to the 90s about turbo pascal and it never outright calls itself object pascal and still does procedural programming. ---------------------------------------------------------------------- lucamar · 2021-02-06 23:03 Quote from: etet on February 06, 2021, 11:48:32 pmCan't I support both OOP and straight procedural bindings? Of course! Depends on how much work you want to invest, though note that an OO implementation can make use of a procedural one "under the hood" so it might not be too much effort. QuoteI've read books dating back to the 90s about turbo pascal and it never outright calls itself object pascal and still does procedural programming. Borland didn't start calling their Pascal "Object Pascal" until Delphi. Previously (since TP 5.5 up to 7.0) it was called "Pascal with Objects", most probably to avoid confussion with Apple's "Object Pascal". And as a publicity stunt, of course: "the Pascal you know and love, now with objects!" Note that objects are usually seen as a (some say "natural") extension to procedural Pascal so there are not really two languages but compilers supporting one or both paradigms. With compilers that support both (like Borland/Turbo, Delphi and Free Pascal) you can freely use either paradigm or a combination of both, which is probably the most usual. Quote from: etet on February 06, 2021, 11:19:18 pmShould I target GNU pascal? Object pascal? Regular pascal? free pascal? Is there a subset of pascal that can target all dialects? The "subset" is what you call "regular Pascal", and with that you can target almost any compiler. Note, though, that GNU Pascal (which was intended as a standard-compliant compiler) has been dead (though still "kicking" from time to time) for quite a lot of years so I would suggest you to target/use Free Pascal which is probably the only serious alternative still in existence and, furthermore, can probably understand most "dialects" still in use. ---------------------------------------------------------------------- etet · 2021-02-07 12:21 Quote from: lucamar on February 07, 2021, 12:03:09 amQuote from: etet on February 06, 2021, 11:48:32 pmCan't I support both OOP and straight procedural bindings? Of course! Depends on how much work you want to invest, though note that an OO implementation can make use of a procedural one "under the hood" so it might not be too much effort. QuoteI've read books dating back to the 90s about turbo pascal and it never outright calls itself object pascal and still does procedural programming. Borland didn't start calling their Pascal "Object Pascal" until Delphi. Previously (since TP 5.5 up to 7.0) it was called "Pascal with Objects", most probably to avoid confussion with Apple's "Object Pascal". And as a publicity stunt, of course: "the Pascal you know and love, now with objects!" Note that objects are usually seen as a (some say "natural") extension to procedural Pascal so there are not really two languages but compilers supporting one or both paradigms. With compilers that support both (like Borland/Turbo, Delphi and Free Pascal) you can freely use either paradigm or a combination of both, which is probably the most usual. Quote from: etet on February 06, 2021, 11:19:18 pmShould I target GNU pascal? Object pascal? Regular pascal? free pascal? Is there a subset of pascal that can target all dialects? The "subset" is what you call "regular Pascal", and with that you can target almost any compiler. Note, though, that GNU Pascal (which was intended as a standard-compliant compiler) has been dead (though still "kicking" from time to time) for quite a lot of years so I would suggest you to target/use Free Pascal which is probably the only serious alternative still in existence and, furthermore, can probably understand most "dialects" still in use. How should I go about making pascal bindings for godot? Should I start with regular procedural pascal and add OOP support later? ---------------------------------------------------------------------- lucamar · 2021-02-07 18:17 I know absolutely nothing about godot (in computers, that is, though I know a lot about Beckett's Waiting for Godot) but most probably you should start with procedural bindings and, if needed afterwards, build classes using them. Note, though, that if godot's API is object-based you'll have to make a "flattening" library to interface with Pascal. A good example of this kind of solutions is how the LCL interface with Trolltech's Qt (C++ objects) is built: the QT4Pas lib flattens the C++ API to procedural C and the LCL uses this to (re)build the widgetset into normal LCL classes. Not exactly easy and quick, perhaps, but doable. ---------------------------------------------------------------------- Leledumbo · 2021-02-07 18:40 Quote from: etet on February 06, 2021, 11:48:32 pmCan't I support both OOP and straight procedural bindings? Sure, the fpGTK package uses the procedural bindings and build an OO version on top of it, for instance. That's the most common way to write bindings of external libraries, as interfacing with procedural C is the least problematic way than dealing with multiple name mangling implementations used by OO languages that's compiler specific. If you want to write libraries for others, which is the opposite what you're trying to achieve, then it's preferrable to write the hardcore logic in OO then make a procedural interface for it. Take a look at one of my projects for inspiration. ---------------------------------------------------------------------- etet · 2021-02-07 18:58 Quote from: Leledumbo on February 07, 2021, 07:40:56 pmQuote from: etet on February 06, 2021, 11:48:32 pmCan't I support both OOP and straight procedural bindings? Sure, the fpGTK package uses the procedural bindings and build an OO version on top of it, for instance. That's the most common way to write bindings of external libraries, as interfacing with procedural C is the least problematic way than dealing with multiple name mangling implementations used by OO languages that's compiler specific. If you want to write libraries for others, which is the opposite what you're trying to achieve, then it's preferrable to write the hardcore logic in OO then make a procedural interface for it. Take a look at one of my projects for inspiration. What I meant by support both OOP and straight procedural is have my bindings support both OOP and straight procedural at the same time so I or another programmer can pick either one. Is that possible? What if I used a library that uses OOP? Would I be forced for the rest of it be written in OOP? ---------------------------------------------------------------------- Sieben · 2021-02-07 22:52 OOP is just an extension of 'procedural' Pascal, so you can use any 'dialect' capable of OOP to write 'straight procedural' as well. Main feature of OOP is the integration of data with code. A common example is the programmatic representation of a person - with 'straight procedural' programming you would for example have variables 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 Person1FirstName: string;Person1LastName: string; and you would have a function like this to get it's full name: Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function GetFullName(AFirstName, ALastname: string): string;begin  Result := AFirstName + ' ' + ALastName;end; With OOP you would have an object called TPerson that would (very roughly) look 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 TPerson = class(TObject)  FFirstName: string;  FLastName: string;  function GetFullname: string;end;...function TPerson.GetFullName: string;begin  Result := FFirstName + ' ' + FLastName;end; Note that now you don't need to specify parameters for function GetFullName, because the object 'knows' on which data to operate. This alone can make programming much more flexible and easier to maintain as any object always carries it's data with it and it's guaranteed to be in scope whenever one of the object's methods are called. Other interesting feature is inheritance. Suppose that in some but not all cases you need additional data like the age of a person. You simply create a descendant of TPerson called TPersonOfAge that only implements calculating it's age based on it's birthday. Next you decide to add a middle initial to TPerson and to rewrite it's GetFullname accordingly. You need not touch TPersonOfAge at all for automatically 'inheriting' this new feature as well. I apologize if I'd carried coals to newcastle... ---------------------------------------------------------------------- etet · 2021-02-07 23:23 Here is the sources for the gdnative API for godot. I want to make pascal bindings for it. h2pas, even with h2paspp, just gives me a syntax error with no explanation why. https://github.com/godotengine/godot_headers How should I go about making pascal bindings for godot? ---------------------------------------------------------------------- Leledumbo · 2021-02-08 05:05 Quote from: etet on February 07, 2021, 07:58:42 pmWhat I meant by support both OOP and straight procedural is have my bindings support both OOP and straight procedural at the same time so I or another programmer can pick either one. Is that possible? What if I used a library that uses OOP? Would I be forced for the rest of it be written in OOP? That's what I'm talking about. You can use the same procedural interface as exposed by the original gtk or use the OO wrapper provided by fpGTK.