Generic programming: Difference between revisions

Content deleted Content added
No edit summary
Line 690:
[[VHDL]], being derived from Ada, also has generic abilities.<ref>https://www.ics.uci.edu/~jmoorkan/vhdlref/generics.html VHDL Reference</ref>
 
[[C (programming language)|C]] has a feature called "type-generic expressions" using the {{c-lang|_Generic}} keyword:<ref name="N1516">[https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1516.pdf WG14 N1516 Committee Draft — October 4, 2010]</ref> This feature gives cC [[function overloading]] capabilities, but is not related to generic programming. Generic programming can be achieved by using the preprocessor to define the generic code, with macro expansion taking the role of ''instantiation''. Sometimes, the non-standard extension "statement expressions" is used to simulate function -like behaviour for generic code:
<syntaxhighlight lang="c">
#define max(a,b) \