Jürgen Hestermann schrieb:

function SerRead(Handle: TSerialHandle; var Buffer; Count: LongInt): LongInt;
   begin
   Result := fpRead(Handle, Buffer, Count);
   end;
i don't understand the declaration for "buffer" in the function below, because no type is declared for "buffer".

Untyped parameters date back to early TurboPascal.

http://www.freepascal.org/docs-html/ref/refsu48.html

    Variable and constant parameters can be untyped. In that case the
    variable has no type, and hence is incompatible with all other
    types. However, the address operator can be used on it, or it can be
    can passed to a function that has also an untyped parameter. If an
    untyped parameter is used in an assigment, or a value must be
    assigned to it, a typecast must be used.

This can be used when you create a variable to use as a block of memory, for a buffer. The size of the buffer has to be known to the function, so it would typically be passed in as a parameter.

I'd guess the reason for adding these to the language is that the caller has to have a variable to pass, so you are less likely to pass an invalid pointer, i.e. one which has not been set to point at allocated memory.

FP

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to