Forum > General

OOP structures in fpc and Lazarus

<< < (10/14) > >>

PascalDragon:

--- Quote from: howardpc on November 30, 2021, 10:29:16 am ---Classes:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TpostTurboPascalClass = class(TObject)...end;confusingly all descend from "TObject" but this is not a TurboPascal object, but a more complex and more capable construct. The naming was defined by Borland, not by FPC which uses it only to be compatible. However it is a source of confusion for newcomers.

--- End quote ---

To add to the confusion: there exists a TObject that is a TP-style object in the Objects unit as that is the base type for Turbo-/FreeVision. :-\

MarkMLl:

--- Quote from: ArtLogi on November 30, 2021, 12:58:56 pm ---PS. Isn't type SET also a primitive object datatype, kind of list-object as lack of better description.  :-\

--- End quote ---

Set is one of the fundamental types which Wirth put into the language at its inception, and (simplifying somewhat) comprises the individual bits in a register or memory location. It shouldn't be considered as a list, since it is by definition unordered.

My simplification was that the limit on a set is generally implementation-defined but somewhat larger than the number of bits in a word. 256 was typical until comparatively recently, i.e. enough to represent the ASCII character set.

MarkMLl

Warfley:

--- Quote from: ArtLogi on November 30, 2021, 12:58:56 pm ---PS. Isn't type SET also a primitive object datatype, kind of list-object as lack of better description.  :-\

--- End quote ---
Yes. Sets in pascal are, unlike in other languages like Python, Swift or C++, not general sets, but Bitset, i.e. their size is known at compile time and their access is always in constant time (with bit operations). Originally they where introduced into pascal to have a more highlevel concept representing the bit-flags typically used by C programs.
For example, where a C program would get an integer where you OR your flags together as an argument, Pascal provides a set, where you can do set operations (like union and inclusivity checks) on. Technically the same things happen, you can also cast sets into bit words (like integers), it's just a more high level construct. Originally pascal also did not have bit operations, as it was intended that everything should be done with sets
But due to the compatability with bit words, they are restricted only to datatypes directly representable as Integers (theoretically every data can be represented as an integer but thats not considered)

marcov:

--- Quote from: Warfley on November 30, 2021, 02:40:19 pm ---Technically the same things happen, you can also cast sets into bit words (like integers), it's just a more high level construct.

--- End quote ---

Note that it is not, as it is a kind of like a higher level intrinsic. If the CPU supports bit level addressing or explicit bit set instructions, it can use these instead of and and orring.

Of course some of the more advanced compilers have ways of detecting a clean AND or OR to a value, and convert it. But the fact that many embedded C compilers (Keil, Microchip) have extensions for bit level access seems to indicate it is not that simple.

jollytall:

--- Quote from: ArtLogi on November 30, 2021, 12:58:56 pm ---For the angry answer

--- End quote ---
I don't know if you mean me had an angry answer, but if that is what you feel, you feel it wrong. There was nothing angry in it, (hence the 'Please' and the mentioning that I had the same confusion).


--- Quote from: ArtLogi on November 30, 2021, 12:58:56 pm ---PS. Isn't type SET also a primitive object datatype, kind of list-object as lack of better description.  :-\

--- End quote ---
Sets are covered by the experts in the last few posts in details, so I cannot add much to it. I however mentioned it in Chapter 2.2 as a structure (like e.g. arrays as well) that I do not deal with, as for OOP they have no relevance.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version