A
A
alliumnsk2021-06-11 11:50:01
Programming languages
alliumnsk, 2021-06-11 11:50:01

What languages ​​are there in which there are unmanaged pointers and garbage collectors in parallel?

In C++/CLI, which was created by Microsoft for a specific purpose, bare pointers (*) and garbage collectors (^) exist in parallel, and objects in both have polymorphism. What other languages ​​have such features?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily Bannikov, 2021-06-11
@vabka

C++/CLI is specifically designed to be the glue between .NET and native code, which is why there are two kinds of pointers/references.
C# has a type for pointers - IntPtr (aka nint) and the pointers themselves (with an asterisk). Asterisk pointers can only be used in unsafe code. And "garbage" pointers are ordinary instances of classes.

A
Alexey Bereznikov, 2021-06-12
@gdt

Garbage-collecting, as you say, pointers in C++/CLI are not exactly pointers, but object handles - see https://docs.microsoft.com/en-us/cpp/extensions/ha... :
The handle declarator (^ , pronounced "hat"), modifies the type specifier to mean that the declared object should be automatically deleted when the system determines that the object is no longer accessible.
If that's exactly what you need (so that the object is automatically deleted when no one else needs it) - then regular C++ is perfect here, its smart pointers do just that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question