Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
language:interface [2023/04/09 23:01] – [Parameter types] rajitlanguage:interface [2025/10/06 11:10] (current) – [Interfaces with functions and macros] rajit
Line 89: Line 89:
 Process type (''ptype'') parameters for templates use the ''@'' character (as in ''@onebit'') in the example above. Process type (''ptype'') parameters for templates use the ''@'' character (as in ''@onebit'') in the example above.
  
 +==== Interfaces with functions and macros  ====
 +
 +An interface type can also include function and macro prototypes. 
 +
 +<code act>
 +export template<pint N> interface policy() 
 +{
 +  methods {
 +     function idx() : int<N>;
 +     macro update(int<N> v);
 +  }
 +}
 +</code>
 +
 +This defines an interface that exports two methods. Note that, unlike port parameters, method names cannot be changed when a type exports an interface.