Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Macro (computer science)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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!
==Parameterized and parameterless macro{{anchor|Parameterized macro|Parameterized|Parameterless}}== A '''parameterized macro''' is a macro that is able to insert given objects into its expansion. This gives the macro some of the power of a [[function (computer science)|function]]. As a simple example, in the [[C (programming language)|C programming language]], this is a typical macro that is ''not'' a parameterized macro, i.e., a '''parameterless macro''': '''#define''' PI 3.14159 This causes <code>PI</code> to always be replaced with <code>3.14159</code> wherever it occurs. An example of a parameterized macro, on the other hand, is this: '''#define''' pred(x) ((x)-1) What this macro expands to depends on what [[argument (computer science)|argument]] ''x'' is passed to it. Here are some possible expansions: pred(2) β ((2) -1) pred(y+2) β ((y+2) -1) pred(f(5)) β ((f(5))-1) Parameterized macros are a useful source-level mechanism for performing [[inline expansion|in-line expansion]], but in languages such as [[C (programming language)|C]] where they use simple textual substitution, they have a number of severe disadvantages over other mechanisms for performing in-line expansion, such as [[inline function]]s. The parameterized macros used in languages such as [[Lisp programming language|Lisp]], [[PL/I]] and [[Scheme (programming language)|Scheme]], on the other hand, are much more powerful, able to make decisions about what code to produce based on their arguments; thus, they can effectively be used to perform [[run-time code generation]].
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Macro (computer science)
(section)
Add topic