Programs or functions that alter the behavior of other programs or functions.
Questions tagged [meta-programming]
30 questions
112
votes
22 answers
Automatic programming: write code that writes code
After reading the book The Pragmatic Programmer, one of the arguments I found most interesting was "write code that writes code".
I tried searching over the net for some more explanations or articles about it, and while I found some good articles on…

Jose Faeti
- 2,815
- 2
- 23
- 30
105
votes
10 answers
Is it ok to use meta-programming even though not all of my colleagues understand it?
I employ a lot of meta-programming to avoid repetitive tasks and build safer-to-use abstractions.
I recently moved to a new job where I am working in a larger team and this worries some of my colleagues, because they do not comprehend it.
I always…

kamikaze
- 1,060
- 2
- 7
- 9
21
votes
4 answers
Is there a downside to using AggressiveInlining on simple properties?
I bet I could answer that myself if I knew more about tools to analyze how C#/JIT behaves but since I don't, please bear with me asking.
I have simple code like this :
private SqlMetaData[] meta;
private SqlMetaData[] Meta
{
…

Serge
- 861
- 2
- 6
- 12
20
votes
3 answers
Must I think about compiled machine code when I write my code?
For example I've got following code:
auto z = [](int x) -> int {
if (x > 0) {
switch (x) {
case 2: return 5;
case 3: return 6;
default: return 1;
}
}
return 0;
};
And later…

cnd
- 1,874
- 1
- 14
- 19
16
votes
5 answers
Is monkeypatching considered good programming practice?
I've been under impression, that monkeypatching is more in quick and dirty hack category, rather than standard, good programming practice. While I'd used from time to time to fix minor issues with 3rd party libs, I considered it temporary fix and…

vartec
- 20,760
- 1
- 52
- 98
12
votes
1 answer
What practical problem results from lack of hygienic macros in Clojure?
I've heard that Clojure macros are easier to write but not as reliable as Racket's hygienic macros. My question has 2 parts:
How does gensym differ from hygienic macros?
What do Racket macros provide that Clojure's don't? (be it safety,…

Alex
- 284
- 1
- 4
12
votes
3 answers
C++: Metaprogramming with a compiler API rather than with C++ features
This started out as a SO question but I realized that it is quite unconventional and based on the actual description on the websites, it might be better suited to programmers.se since the question has a lot of conceptual weight.
I have been…

Steven Lu
- 509
- 4
- 11
12
votes
3 answers
Compile-time IOC
Has anyone started a project to do IOC at compile time (possibly using Roslyn or Linq MethodInfo emit)?
My experience with IOC containers has thus far been great, baring a few small issues
Many IOC containers are slow to start up, as much of the…

ArTs
- 720
- 5
- 12
10
votes
4 answers
How common is meta-programming?
How often do you or have you seen meta-programming be used in projects? In uni I've never seen this be applied, but I've seen this on my previous job (when I saw it I was blown away of how effective it was).
But how common is it? Is it used all the…

gablin
- 17,377
- 22
- 89
- 138
7
votes
1 answer
Loop fusion example using aspect-oriented framework
I had recently read a paper 'Aspect-Oriented Programming' by Gregor Kiczales and others, and found there the loop fusion example.
Here is a definition of the loop fusion from the paper
…the loop fusion composes by fusing the loops of those…

Akim
- 999
- 7
- 16
7
votes
2 answers
Are there any reliable solutions for annotations/reflection/code-metadata in C?
Not all languages support java-like annotations or C#-like attributes or code metadata in general, however that doesn't mean it is not possible to have in languages that don't have this.
An example is PHP with Stubbles and the Doctrine annotation…

dukeofgaming
- 13,943
- 6
- 50
- 77
6
votes
6 answers
How to do pragmatic high-level/meta-programming?
Imagine you have implemented the creation of a nice path-based star shape in Lisp. Then you discover Processing and you re-implement the whole code, because Processing/Java/Java2D is different. Then you want to tinker with libcinder, so you port…

LennyProgrammers
- 5,649
- 24
- 37
6
votes
1 answer
s expression representation for c
Experimenting with various lisps lately (clojure especially) i have wondered if there are any s expression based representations of (subsets) of c, so you could use lisp/closure to write macros and then convert the s-expression c tree to pure c.
I…

wirrbel
- 3,018
- 2
- 21
- 33
5
votes
3 answers
Metaobject protocol:Why is it known as an important concept
Metaobject protocol is protocol for metaobjects in a programming languages. Although I understand it on simple terms, I want to know the reason and a summary of real world usage patterns of this protocol. So, why exactly is metaobject and more…

sushant
- 221
- 1
- 4
5
votes
1 answer
Is tag dispatch as used in CppCoreGuidelines T.65 antiquated?
The CppCoreGuidelines contain the following:
T.65: Use tag dispatch to provide alternative implementations of a function
[...]
Example
struct pod_tag {};
struct non_pod_tag {};
template struct copy_trait { using tag = non_pod_tag;…

Jan Schultke
- 159
- 2