﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="thpdoc.xsl"?>
<page id="typeof" suffix=" Function">
  <subsection>Returns the type of a variable, signal, port, entity instance or an expression.</subsection>
  <code>any typeof(any object);</code>
  <section name="Remarks">
	<p>Note that THDL++ supports type inference. If a declaration has an initializer, the <kw>auto</kw> keyword can be used instead of an explicit <kw>typeof</kw>.</p>
  </section>
  <examples>
	<example name = "Signals">
	A typical use case for <kw>typeof</kw> - declaring a signal that has the same type as some other signal:
		<code>entity Test
{
	port in logic[8] Input;
	signal typeof(Input) PrevInput;
}</code>
	</example>
	<example name="Expressions">
	<kw>typeof</kw> can also be used with expressions:
	<code>signal typeof(Input cat Input) PrevInput;</code>
	</example>
	<example name="Entities">
	You can also declare "an instance of the same entity as the given instance":
<code>entity Test
{
	Core.RAMs.Synchronous.SimpleRAM RAM1(
		...
	);
	
	typeof(RAM1) RAM2(
		...
	);
}</code>
	</example>
  </examples>
  <seealso id="sizeof"/>
  <seealso id="auto"/>
  <seealso id="any"/>
</page>