Hacker News new | ask | show | jobs
by twic 1270 days ago
> as long as you follow very simple convention with TObject.Create() and TObject.Free; you won't have memory safety problems

Is this the same as how in C, as long as you follow very simple convention with malloc() and free() you won't have memory safety problems?

1 comments

not only that, Object pascal has very nice way of separating code and avoiding globals, and variables were constrained within certain scope. Each module is compiled independently and no macro hell.

if you were to pass reference around, then compiler would warn about potentially dangerous Free.

I don't remember ever seeing Pascal code where you received raw pointer and then directly casted it to your object type for example. Pascal has very powerful and expressive type system