Hello everybody. My message is for both "Why use pointers to arrays?" and "Illogical automatic deferencing".
I really don't understand why Pascal "should" include C-style stuff. PASCAL IS DIFFERENT LANGUAGE THAN C. STOP. Actually I hate that "C-lovers" that think all languages must use C-style stuff inside any other languages. I'm using C right now, as well as Pascal, and I really think that C is a great language for some tasks (i.e. low-level) but it isn't the panacea ("the solution for everything"). You'll never add C-style stuff inside SQL, do you? So, why do you want C-style stuff in Pascal? As I've said, C language is useful sometimes, but it's ugly and prone to runtime errors. A lot of that runtime errors are compilation-time errors on Pascal, so they're easer to find and to fix for me (just the opposite that somebody said in this discussion). That's why I love to use Pascal. It's less frustrating. A lot. If you have "p: PINTEGER" then you're assuming you're accessing to ONE integer. If you need to access to an array of integer then use a pointer to an array. What's the problem with "p^[3]"? I think it is better because you see you're accessing to a pointer to an array, and in most cases it's important to don't forget it. When I use C, I try to do not use pointers as arrays. I write something as: /* Useless example function. */ char Fn (int Ndx) { char AnArray[500]; char *Pointer; Pointer = &(AnArray[0]); return *(Pointer + Ndx); /* instead of "return Pointer[Ndx];" */ } This is more readable, because "*(Pointer + Ndx)" remembers me that it's a pointer, not an array, so may be it wasn't assigned and may be it needs some test before to use it (i.e. "if ( ! Pointer) return EXIT_FAILURE;" or something). As conclusion: I think that Pascal is good as it is. Of course it can evolve to be better, but I think it doesn't need that C-style stuff (i.e. Object Pascal has it's own approach to OOP keeping the original "Pascal-style" and I like it much more than C++ and C# [can't say the same about Objective C ;) ]). Greetings, Guillermo "Ñuño" Martínez _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal