Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I wrote an article about this very topic a few years ago:</p> <blockquote> <p><a href="http://www.cs.wisc.edu/~rkennedy/untyped" rel="noreferrer">What is an untyped parameter?</a></p> </blockquote> <p>Untyped parameters are used in a few situations; the <code>TStream.Read</code> method you ask about most closely matches with the <code>Move</code> procedure I wrote about. Here's an excerpt:</p> <blockquote> <pre><code>procedure Move(const Source; var Dest; Count: Integer); </code></pre> <p>The <code>Move</code> procedure copies data from an arbitrary variable into any other variable. It needs to accept sources and destinations of all types, which means it cannot require any single type. The procedure does not modify the value of the variable passed for <code>Source</code>, so that parameter’s declaration uses <code>const</code> instead of <code>var</code>, which is the more common modifier for untyped parameters.</p> </blockquote> <p>In the case of <code>TStream.Read</code>, the source is the stream's contents, so you don't pass that in as a parameter, but the destination is the <code>Buffer</code> parameter shown in the question. You can pass any variable type you want for that parameter, but that means you need to be careful. It's <em>your</em> job, not the compiler's, to ensure that the contents of the stream really are a valid value for the type of parameter you provide.</p> <p>Read the rest of my article for more situations where Delphi uses untyped parameters.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload