Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Generic programming
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Other languages=== Languages in the [[ML (programming language)|ML]] family support generic programming through [[parametric polymorphism]] and generic [[Modular programming|modules]] called ''functors.'' Both [[Standard ML]] and [[OCaml]] provide functors, which are similar to class templates and to Ada's generic packages. [[Scheme (programming language)|Scheme]] syntactic abstractions also have a connection to genericity β these are in fact a superset of C++ templates. A [[Verilog]] module may take one or more parameters, to which their actual values are assigned upon the instantiation of the module. One example is a generic [[Hardware register|register]] array where the array width is given via a parameter. Such an array, combined with a generic wire vector, can make a generic buffer or memory module with an arbitrary bit width out of a single module implementation.<ref>Verilog by Example, Section ''The Rest for Reference''. Blaine C. Readler, Full Arc Press, 2011. {{ISBN|978-0-9834973-0-1}}</ref> [[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]] supports "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> <syntaxhighlight lang="c"> #define cbrt(x) _Generic((x), long double: cbrtl, \ default: cbrt, \ float: cbrtf)(x)</syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)