Hello, I would like to know whether (or why) GPC makes strict type checking on procedure parameters passed as const. In a program like this: ---------------------------------- program tester; type firstobj=object end; secondobj=object(firstobj) end;
procedure test(f:firstobj); begin end;
var o:secondobj;
begin test(o); end. ---------------------------- the compiler reports:
tester.dpr:9: objects must not be value parameters tester.dpr: In main program: tester.dpr:16: illegal explicit assignment between objects
The second error seems a little misterious for me, but it doesn't matter, maybe some errors recovery problem. I understand the reasons for not passing objects by value, so I tried to replace the procedure header by
procedure test(const f:firstobj);
but then passing an object derived from ffirstobj I get an error: tester.dpr:16: type mismatch in argument 1 of `Test'. So my question is - do I have to write such procedures in GPC as
procedure test(var f:firstobj); ?
I know I should probably use pointers to objects, but for some reason I would like to use this realization. Can someone explain me that? Regards, Adam Naumowicz
-------------------------------------- WWW: http://math.uwb.edu.pl/~adamn/ --------------------------------------
On 31 May 2001, at 13:48, Adam Naumowicz wrote:
Hello, I would like to know whether (or why) GPC makes strict type checking on procedure parameters passed as const.
[...]
I think that it is a GPC bug (or feature, if you like ;)).
Best regards, The Chief --------- Prof. Abimbola Olowofoyeku (The African Chief) Author of Chief's Installer Pro for Win32 Email: African_Chief@bigfoot.com http://www.bigfoot.com/~african_chief/