Hi guys

Hi guys,

I am confused with something I saw in a snippet. There was a procedure defined like this:

procedure myProc (const aConst; var aString: string);

Does this mean that aConst can be anything? and how do we manage it inside the procedure? by typecasting?

Thanks

Comments

  1. John Kouraklis you can't use proc(1234) or proc(DUMMY) where DUMMY = 4567;

    ReplyDelete
  2. Paul TOTH Aha, but you can define const DUMMY: integer = 4567 and then pass it?

    ReplyDelete
  3. John Kouraklis You can think of "const aParam" as "const aParam: pointer", and when you call it, for example "myProc(someVar)", you can think of it as "myProc(@someVar)".

    This is why you cannot pass it an untyped numerical constant, because those do not have storage (and hence no memory address). The typed numerical constant like you mentioned is just a variable marked const, which does have storage (and hence a memory address).

    ReplyDelete

Post a Comment