[fpc-pascal] TStringStream.DataString returns garbage?

Lars noreply at z505.com
Wed Feb 1 23:45:08 CET 2012


Graeme Geldenhuys wrote:
> On 2 February 2012 00:14, Michael Van Canneyt  wrote:
>>
>> Ehm.. this should be S[1], now you're writing the pointer.
>
>
> Thank you. That's what happens if you have too many very late nights
> programming - sleep deprivation catches up and one overlooks the
> simple mistakes.
>
>
>

It's actually a common mistake. Also @s vs "s", and @s[1], it can be
confusing.

It's one thing I don't like about unsafe languages, pointers, and such
stuff. It's as if we are programming in advanced C, or C++. Common,
pointer mistakes? this is C? Really? Can't we make it safer? LOL.

What could be done to make this safer? I don't know. What does java do in
a situation like this? Could we learn from it?

If somehow the compiler could statically check that only s[1] is allowed, 
and not S, that would be good.



More information about the fpc-pascal mailing list