Forum > Other

Pascal and Cousins

<< < (4/5) > >>

marcov:

--- Quote from: vfclists on February 02, 2021, 06:01:12 pm ---do you gain the benefits of reference counting on most other types in general, including your own?

Are there any base classes from which any other derived types gain the benefits of reference counting?

--- End quote ---

Ref counting is only better than GC for limited use.

PascalDragon:

--- Quote from: vfclists on February 02, 2021, 06:01:12 pm ---Are there any base classes from which any other derived types gain the benefits of reference counting?

--- End quote ---

You need to work with reference counted interfaces (aka {$Interfaces COM} which is the default) and implement its _AddRef and _Release methods correctly. Alternatively (and preferably) you can descend from TInterfacedObject (which does exactly that), but you still need to work only with interface variables as working with the class instance will not trigger the reference counting.

JuhaManninen:
vfclists, manual memory management is easy in vast majority of cases. An object is owned by another object. The owner allocates and frees the memory.
Thinking the ownership structure through may even improve your code's design.

Garbage collection does not solve all memory related problems. Java has CG but there are thick books written about Java memory management. Why so, if GC takes care of it all?
Also GC does not fix uninitialized variables.
IMO garbage collection is overrated. If you however prefer it, fine, there are plenty of choices. All new fancy languages seem to have it.
Object Pascal is a nice compromise without GC, thus less overhead, but reference counted strings which then behave almost like native types (integer and such). Good.

MarkMLl:
I went Googling yesterday evening to try to find out whether anybody had built a general-purpose OO language on top of ALGOL (other than Simula, obviously) and came across "A comparison of PASCAL and ALGOL 68" by Tanenbaum.

https://research.vu.nl/en/publications/a-comparison-of-pascal-and-algol-68

It's rather a gem, and I'm surprised it's not got wider circulation. However it appears to "read quite a lot into" J&W's definition of the language, for example it asserts that pointers can refer to items on the heap but not to items on the stack.

Perhaps the most interesting thing is that, reading between the lines, it demonstrates that much that we are used to in today's mainstream languages originated /either/ in ALGOL-68 /or/ in Pascal: the concept differed in the two languages, and posterity has selected from one or the other.

MarkMLl

lucamar:

--- Quote from: MarkMLl on February 14, 2021, 12:49:02 pm ---[...] came across "A comparison of PASCAL and ALGOL 68" by Tanenbaum.

https://research.vu.nl/en/publications/a-comparison-of-pascal-and-algol-68

It's rather a gem, and I'm surprised it's not got wider circulation.
--- End quote ---

One has always to be careful and remember that this kind of papers refer to the original J&W Pascal but yes, it's quite a gem. Thanks, Mark, I've enjoyed it a lot :)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version