IDE, Project options - needed option for "Typed Pointers"
Pascal the language is all about safety and predicatbility.
It's ideal is having strict type system, catching errors in compile time.
Sadly, there is a glaring hole in this, by default pointer operator @object
is untyped, and anything can be assigned to any pointer variable (if it was enough that pointers were not dangerous per se).
There is a local-scope $T switch - https://www.freepascal.org/docs-html/current/prog/progsu75.html#x82-810001.2.75
But being local-scope it should be repeated in every unit of the project. Or some other tricks, like include-files, may be employed by seasoned programmers. Still, not enough.
-
Pascal is to be safe for new, inexperienced programmers too! Those would, perhaps, learn seeing checkboxes in Project Options / Parsing / Syntax window, like it was done in Delphi. Without seeing it they would, maybe, never know such a feature exists in FPC too, not only in Delphi, and even if they would - they would have troubles to uplift it to project-global or IDE-global default state. Easy to find checkbox is needed.
-
Ideally, "typed pointers" should become the default for new projects. Better safe than sorry.
-
Code tools, code completion. It should account for this setting when suggesting identifiers after Ctrl+Space.
Sadly, currently it seems types are not accounted for at all. But eventually they should. And then code-completing leads like @ab
shoul give different results in $T+ and $T- modes.