Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
CppCoreGuidelines
The C++ Core Guidelines are a set of tried-and-true guidelines, rules, and best practices about coding in C++
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
class Pointer(Generic[T]): """Base class representing a pointer.""" def init(self, address: int, typ: Type[T]) -> None: self._address = address self._type = typ ... def dereference(self) -> T: """Dereference the pointer.""" return dereference_address(self.address) ``` https://github.com/ZeroIntensity/pointers.py/blob/master/pointers.py
I'm reminded of the FAQ for a Javascript error steamroller, fuckit.js:
Note it's just using the ctypes ffi package which is in the CPython standard library itself anyway. You sure can fuck around and find out with that. But it's also kinda what it's there for - using ctypes is e.g. how things like the python SDL2 wrappers are implemented: https://github.com/py-sdl/py-sdl2
There are also great efforts by legendary people such as Bjarne Stroustrup and Herb Sutter to make memory problems a thing of the past in 99% of code even if they have owners that use raw pointers through static analysis. The aim is never to dereference a deleted object (dangling pointers), always to call delete once (no memory leaks), and never to call delete two or more times (no memory corruption). It's only 99% of the time, because a full analysis would take increasingly more time for increasingly complex code. The static analysis, which has been developed and is in testing last I heard, makes assumptions to make the computation time realistic. For example, they make assumptions like a function receiving a raw pointer is not the owner and that the pointer passed in is valid. When each part of the program is checked in this local fashion, it reduces error rates substantially. Here is one recent talk on this effort, showcasing the prototype at that time, a Visual Studio plugin. Here is another talk one year later. There is also a great effort to unify style with a strong preference to avoid error-ridden techniques spearheaded by Herb Stutter and Bjarne Stroustrup (for example by recommending unique_ptr to manage ownership of a raw pointer): https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines