Adriaan van Os wrote:
Prof A Olowofoyeku (The African Chief) wrote:
Mehdi Khaldi wrote:
Hi, Is it possible to use universal pointer like void* in C? I have seen that there is a keyword "univ" with sun compiler. How to do to have universal pointer with gpc?
"Pointer"
Frank Heckenbach wrote:
Adriaan van Os wrote:
(7) Filter out a handful of compiler features that would really assist GPC development on Mac OS X (and porting from CodeWarrior). On this list wil be UNIV parameters, I guess, but this is premature.
No idea what they are ...
Like the Sun compiler, Macintosh Pascal compilers have the UNIV keyword. UNIV is put before the type (after the colon) in parameter lists and says "don't complain if the types of actual parameter and formal parameter don't match, as long as they have the same sizes in bytes".
You may remeber that I heavily criticized some Borland features lately. Well, I like this one even less. First, it adds a new keyword. I think that many dialects (also Borland, in other cases) are adding keywords far too quickly. Most of us know the drawbacks. BP's untyped parameters need no new keyword (though a new syntax rule, which is also not nice, but not as bad as a new keyword), and a `Void' type parameter which I'd prefer (semantically equivalent to BP's untyped parameters) would do neither (just a predefined identifier which can simply be redefined).
Secondly, it demands the same size. That's unportable! Pascal doesn't make any statements about type sizes, so you have the effect that a program may compile on one platform and not on another. Sure, you can get such dependencies also by "unclean" code -- but for a core feature (even one manifested in the syntax), sorry no!
The restriction itself is also highly dubious. E.g., on my machine `ShortReal' has the same size as `Integer'. So what? With intimate knowledge of floating point formats, I may be able to do something with a `ShortReal' masked as `Integer' -- and this will break badly on many platforms for many reasons (size, endianness, FP format, ...). So I think if you do such low-level bit-fiddling, you should just tell the compiler that you know what you're doing and to leave you alone, rather than some pseudo-typing or whatever we should call this which may give you a wrong impression of safety ...
Prof A Olowofoyeku (The African Chief) wrote:
On 18 Feb 2003 at 20:48, Adriaan van Os wrote:
[...] (3) typed pointer in procedural parameter list passed as actual
parameter. Works not in GPC and not in Delphi.
And IMHO, it shouldn't.
I agree. What seems to be done is to infer compatibility of procedural parameter types from assignment compatibility of their arguments. That's not quite in the spirit of Pascal where already two distinct types, both declared as `array [1 .. 10] of Integer' are not compatible at all, leave alone arrays of different, though assignment-compatible types. I don't think this should be any less strict for procedural types.
It's also less safe: In your example, `writerec' expects its argument to be of type `recptr'. But the procedural parameter usage breaks this. That's unlike `writeptr' where the procedure declares its argument so, so the implementation of the procedure can handle the issue. So the extension of procedural types basically allows you to pass anything to any parameter, without any explicit type-casts or such (which would make the possible dangers obvious).
Frank