Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes I know these workarounds but I don't think they are better than typedefs. Instead I simply want the obvious and readable thing that doesn't try to hide what happens and that doesn't require extra keyboard typing.


> I don't think they are better than typedefs

Why? Passing a record by reference looks like this: procedure SomeProc(var AMyRec : TMyRecord);

Passing an object reference looks like this: procedure SomeProc(const AMyObj : TMyObject);

I don't see that these are somehow onerous or hiding anything.


Sure. When used they look like normal variables. And when you set them it looks like setting a local variable. This is hiding that what really happens is it's writing through a pointer. And it's modifying the caller's state.

Add to that the unfounded non-orthogonality (like in C++, references are technically the same as pointers, but not syntactically, and not in the type system, leading to combinatorial explosion. And of course the bloated standard library is proof).

Furthermore this approach doesn't work for pointers that point to arrays. Again, Delphi has its own zoo of workarounds that OOP enthusiast will think are so much better -- from dynamic arrays (really weird interactions with reallocations combined with "var" modifier or not), to ObjectLists (not typed) to a version of generics (has its own technical problems). But what I want is the simple and obvious thing (pointer parameters without typedefs) and there's no good reason why we shouldn't have it.


> This is hiding that what really happens

There is no ambiguity and nothing is hidden. Both examples are passing a reference to the procedure and all Pascal programmers will know what it means.

I think your argument boils down to a lack of experience with Pascal (which is fine). But these things you think are problems simply aren't.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: