Programs or functions that alter the behavior of other programs or functions.

learn more… | top users | synonyms

74
votes
22answers
39k views

Automatic programming: write code that writes code [closed]

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 ...
19
votes
3answers
2k views

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; ...
12
votes
5answers
3k views

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 ...
10
votes
4answers
514 views

How common is meta-programming? [closed]

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 ...
9
votes
2answers
382 views

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 ...
7
votes
1answer
478 views

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 ...
6
votes
6answers
373 views

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 ...
6
votes
2answers
388 views

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 ...
5
votes
2answers
333 views

Example of time-saving usage of compile-time meta-programming?

The webpage of Converge states that: Converge has a macro-like facility that can embed domain specific languages with arbitrary syntaxes into source files. I am most intrigued by the possibility ...
4
votes
3answers
345 views

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 ...
4
votes
1answer
314 views

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 ...
3
votes
3answers
316 views

Is there a name for this functional programming construct/pattern?

I wrote a function and I'd like to find out if it is an implementation of some functional programming pattern or construct. I'd like to find out the name of this pattern or construct (if it exists)? ...
3
votes
1answer
392 views

Good introduction to metaprogramming in Prolog?

I would like to make for example imperative programs as output of Prolog (shaders of graphic card) and also event-driven programs (game logic) ... also I would like to learn how to metaprogram in ...
2
votes
1answer
215 views

Are symbolic programming and metaprogramming the same thing?

Are symbolic programming and metaprogramming the same thing? I've always read about symbolic programming while using Mathematica, but I've never searched about it's meaning, I've searched about it ...
1
vote
5answers
445 views

Is it possible in C++ to define several methods at once?

Sorry for the confusing title of this question, but I can't think of an exact way to word it. I have a very long class with hundreds of similar methods and I am trying to find a way to construct it ...
1
vote
1answer
179 views

What is this programming style? “Monoid-ic”?

In a moderately old blog post, Conal Elliot makes an interesting (if less than serious) argument that C is a purely functional language, by drawing a parallel between the combination of the C ...
0
votes
2answers
101 views

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[] ...
-1
votes
4answers
137 views

Identifier for the “completed” stage of a process: 0, 99, something else?

Say, that you are handling a multi-step process (like a complex registration form, with a number of steps the user has go through in order). You need to be able to save the current state of the ...