1. Explain to me how to use interfaces in freepascal with an example.
2. Is the unique id thing strictly neccesary and what is it's purpose?No. Its for COM programming. "It is used to enable inter-process communication object creation in a large range of programming languages"
COM programmers build their software using COM-aware components. Different component types are identified by class IDs (CLSIDs), which are Globally Unique Identifiers (GUIDs). Each COM component exposes its functionality through one or more interfaces. The different interfaces supported by a component are distinguished from each other using interface IDs (IIDs), which are GUIDs too. COM interfaces have bindings in several languages, such as C, C++, Visual Basic, Delphi, Python[10][11] and several of the scripting languages implemented on the Windows platform. All access to components is done through the methods of the interfaces. This allows techniques such as inter-process, or even inter-computer programming (the latter using the support of DCOM).
3. If the unique id thing is neccesary, then how do i obtain one for the interfaces i am creating.Ctrl+Shift+G
4. If you know, then also explain to me the differences from freepascal's interfaces and Golang's interfaces.Unsure. It looks like Go doesn't have classes, but uses "interfaces", which seems to be an abstract type. Maybe its similar to C++ pure classes, or Pascals abstract classes.
No. Its for COM programming. "It is used to enable inter-process communication object creation in a large range of programming languages"Not necessary. GUID is required for IS and AS operators to work. And these two operators are required for virtual casting to work.
https://en.m.wikipedia.org/wiki/Component_Object_Model
I guess, it's better to read this article (https://wiki.lazarus.freepascal.org/Interfaces).
Well, as a "Classical Pascal" guy I think of myself as being in much the same boat as OP. And every time I try to get to grips with interfaces I come up against something like (from the wiki article cited above):Well, it's actually not my article, so it isn't my example. It's just copy-paste of my post from some other thread about interfaces. Yeah, reference counting is nice thing, but it's not mandatory. One can control object's life time by himself, if he desires to do it.
"You should understand, that there are two kinds of interfaces. ... 1) Interfaces as tool to implement multiple inheritance, as they work in some other languages, like Java 2) OLE/COM interfaces as Windows-specific language-independent way to implement OOP."
But the code example right at the top of that wiki page refers to CORBA, which is neither (1) nor (2). At that point I give up. Again.
It might possibly be safe to say something like "In a component-based system, each underlying component is described by an interface, sometimes with an associated GUID. At the application programming level, multiple interfaces can be grouped together to provide the functionality for an object." But on a system that doesn't have all its functionality in external components, it leaves me wondering what all the fuss is about.
MarkMLl
Well, it's actually not my article, so it isn't my example. It's just copy-paste of my post from some other thread about interfaces. Yeah, reference counting is nice thing, but it's not mandatory. One can control object's life time by himself, if he desires to do it.
Don't worry: I'm definitely not blaming you. But like so many things these days the article is written by somebody who knows what he's explaining, not by somebody who knows how to explain it (if you get my drift).Everybody comes to interfaces sooner or later, as complexity of his tasks grows more and more. It's both good way to implement more complex relations between objects, than standard OOP allows, and to automatically manage objects' life time in order to avoid memory leaks and "use after free" errors without using safe languages, like Rust. And at the end separating declaration from implementation - is actually good practice. Because one can never know, if he will need to split his program into several modules or not.
I've just been taking a look at the CORBA article on Wp (and I've been struggling to get my head around the applicability of this stuff since CORBA, IDL etc. came out in the early '90s). Neither article starts off with a succinct explanation of what an external component might encapsulate, why one can benefit from using that external component, and the reasons that going through something like CORBA is a benefit (e.g. data reorganisation determined by what's in the IDL).
So while I appreciate that while it can be used as a sort of "super RPC" remotely, and that locally it's an alternative to class multiple inheritance, generally speaking I don't see what the fuss is about.
MarkMLl
Everybody comes to interfaces sooner or later, as complexity of his tasks grows more and more. It's both good way to implement more complex relations between objects, than standard OOP allows, and to automatically manage objects' life time in order to avoid memory leaks and "use after free" errors without using safe languages, like Rust. And at the end separating declaration from implementation - is actually good practice. Because one can never know, if he will need to split his program into several modules or not.
Well, I've been using Delphi etc. for substantially more than 20 years, and from my POV there are far more pressing omissions in the language etc. than this addresses.Delphi/FPC can be turned into pseudo-scripted language via: 1) Wrapping all simple types into objects to make them type-compatible (optional) 2) Using interfaces for everything in order to achieve auto object life time management 3) Making good data management library, i.e. implement lists, dictionaries, stacks, queues, etc. Simply because data management - is very common goal. Such as "For number-letter pairs make list of all letters, that has the same number". It's just way too tedious to always rewrite such code from scratch. It should be standard.
I mean, if somebody could demonstrate that this provided a better way of getting at a remote database than ODBC, or a better way of interfacing with a remote user than X11 or Wayland, then I think there would be compelling reasons for promoting it.
MarkMLl
Never put programmers on the wrong foot by promoting CORBA. It has no use other than confuse.I don't think CORBA is very confusing, it is exactly what you think of an interface when you come from any other language. It's just a set of functions and properties your class must provide. The confusing thing is COM interfaces, which have a completely different memory management model from traditional lazarus, require the inheritance from TInterfacedObject and are incompatible with normal pascal code.
First of all, forgett about multi inheritance, this most cerntainly only complicates it
I have looked and looked and
I have looked and looked and
Am I the only one who sees someone having us do his homework for him?
I have looked and looked and
Am I the only one who sees someone having us do his homework for him?
Yes. The OP was a spammer that probably copied this message from sb doing homework. The spam link has been removed and account can't do anything any more so that the discussion was preserved.