Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-other / 2009-10

Re: Illogical automatic dereferencing

5 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Florian Klaempfl
Show quoted text 14 lines
Florian Klaempfl wrote on Tue, 13 Oct 2009: > Jonas Maebe schrieb: >> I think that "all pointers can be indexed as arrays" can easily cause >> accidentantal errors though. I can't find it anymore, but I remember >> Pierre once fixed a bug in the compiler sources itself where someone >> accidentally used move(pstring_var[1],...) instead of >> move(pstring_var^[1],..). That at least was not a case of not >> understanding how pointers work, but a simple case of a typo which >> couldn't be caught anymore by the compiler due to this extension. > > What is the alternative? Only allowing it for pchar/pwidechar, I guess.

Then another person pops up and asks why it is allowed only for pchar/pwidechar being illogical because this is not orthogonal. Besides the fact that I think that the pointer to array work around would be really hacking e.g. due to range checking.

Show quoted text 5 lines
And/or printing a warning in case you are "indexing a pointer" to a type that is an indexed type itself, although I'm not sure how we could make it possible to disable this warning on a case-by-case basis using some kind of explicit syntax saying "yes, I want (pointer+(n-1)*sizeof(pointer))^, not pointer^[n]".

Reply by email

Vinzent Höfler

Reimar Grabowski :

Show quoted text 5 lines
doing. The great thing about Pascal is that you get a mostly clean language with all the power of C/C++. Some parts are not as clean or strict as some people like, but I'd rather have some 'not-so-clean' implementation than a loss in speed or versatility. If pointers are too much for you go and play with Java or Ada.

And one doesn't know what he's talking about, he should just shut up.

Even in Java (which does have pointer data types, yet still it has "references") you need to know which types are by-value and which ones are by-reference (not that this is a particularly hard thing to remember).

And Ada has pointers quite similar to Pascal.

Vinzent.

Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 - sicherer, schneller und einfacher! http://portal.gmx.net/de/go/atbrowser

Reply by email

Jonas Maebe
to Florian Klaempfl: Then another person pops up and asks why it is allowed only for pchar/pwidechar being…

Florian Klaempfl wrote on Tue, 13 Oct 2009:

Show quoted text 5 lines
Jonas Maebe schrieb: > Only allowing it for pchar/pwidechar, I guess. Then another person pops up and asks why it is allowed only for pchar/pwidechar being illogical because this is not orthogonal.

Undoubtedly. I guess the best solution is to have that Delphi switch so everyone can set the behaviour he/she prefers.

Besides the fact that I think that the pointer to array work around would be really hacking e.g. due to range checking.

You can always do (pointertype+x)^, but I guess that's not acceptable either because it doesn't look very nice. It's more explicit about the intention though, imo.

Jonas

---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.

Reply by email

Marco van de Voort
to Jonas Maebe

In our previous episode, Jonas Maebe said:

Show quoted text 5 lines
> Then another person pops up and asks why it is allowed only for > pchar/pwidechar being illogical because this is not orthogonal. Undoubtedly. I guess the best solution is to have that Delphi switch so everyone can set the behaviour he/she prefers.

I guess some choice is fine, but I wouldn't change the default behaviour, except for Delphi mode. It breaks a lot of code (e.g. fcl-image uses it a _lot_)

Reply by email