Re: [fpc-pascal] Another Delphi mode question :) -- classes as parameter

2006-07-13 Thread memsom
What IS true is that you can change the properties of S, even if it is passed by value or as const. But the pointer S cannot be changed. I desired to change the pointer; manifestly I have to pass it as var. Be aware that if you do this, you will lose the ability to pass any class that

Re: [fpc-pascal] Another Delphi mode question :) -- classes as parameter

2006-07-13 Thread Alexandre Leclerc
2006/7/13, memsom [EMAIL PROTECTED]: Be aware that if you do this, you will lose the ability to pass any class that descends from the param type. Var params have to be the smae type exactly. The Delphi compiler will halt on an error if the exact type isn't used (though, thinking about it, the

[fpc-pascal] Another Delphi mode question :) -- classes as parameter

2006-07-12 Thread Alexandre Leclerc
I tried the following: procedure ThisAndThat(bitmap: TBitmap); begin if not Assigned(bitmap) then bitmap := TBitmap.Create; end; function Test: boolean; var bitmap: TBitmap; begin bitmap := nil; ThisAndThat(bitmap); Result := Assigned(bitmap); bitmap.Free; end; In Delphi a class is

Re: [fpc-pascal] Another Delphi mode question :) -- classes as parameter

2006-07-12 Thread Michael Van Canneyt
On Wed, 12 Jul 2006, Alexandre Leclerc wrote: I tried the following: procedure ThisAndThat(bitmap: TBitmap); begin if not Assigned(bitmap) then bitmap := TBitmap.Create; end; function Test: boolean; var bitmap: TBitmap; begin bitmap := nil; ThisAndThat(bitmap); Result := Assigned(bitmap);

Re: [fpc-pascal] Another Delphi mode question :) -- classes as parameter

2006-07-12 Thread Felipe Monteiro de Carvalho
On 7/12/06, Alexandre Leclerc [EMAIL PROTECTED] wrote: In Delphi a class is always treated as a 'var' when passed in a function since a class is a pointer to actual data; No, not really. It is always passed as a pointer, but here you want to change the pointer and not the contents of the

Re: [fpc-pascal] Another Delphi mode question :) -- classes as parameter

2006-07-12 Thread Alexandre Leclerc
2006/7/12, Michael Van Canneyt [EMAIL PROTECTED]: Ahem. Have you tried that ? Because it is manifestly NOT true: Ah! I learnd something today! You are completly correct: What IS true is that you can change the properties of S, even if it is passed by value or as const. But the pointer S

Re: [fpc-pascal] Another Delphi mode question :) -- classes as parameter

2006-07-12 Thread Alexandre Leclerc
2006/7/12, Felipe Monteiro de Carvalho [EMAIL PROTECTED]: On 7/12/06, Alexandre Leclerc [EMAIL PROTECTED] wrote: In Delphi a class is always treated as a 'var' when passed in a function since a class is a pointer to actual data; No, not really. It is always passed as a pointer, but here you