Top "Metaprogramming" questions

Metaprogramming is the capability to reprogram ones programming environment, as with macros or metaclasses.

How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?

In a recent interview, I was asked a really strange question. The interviewer asked me how can I compute 1+2+3+...+1000 just …

c# java c++ compiler-construction metaprogramming
Ruby's def and instance_eval vs. class_eval

I'm reading the Metaprogramming section of Programming Ruby 1.9 and I'm having trouble understanding what's going on internally between class_eval/…

ruby metaprogramming
How to use C++ templates in OpenCL kernels?

I'm a novice in OpenCL. I have an algorithm which uses templates. It worked well with OpenMP parallelization but now …

c++ templates compiler-construction metaprogramming opencl
How to dynamically create instance methods at runtime?

[ruby 1.8] Assume I have: dummy "string" do puts "thing" end Now, this is a call to a method which has …

ruby metaprogramming ruby-1.8
How to find out the arity of a method in Python

I'd like to find out the arity of a method in Python (the number of parameters that it receives). Right …

python metaprogramming
Petri net drawing and code generation

Is there any software for drawing a Petri net and generating any source code from there? The source code could …

automation code-generation metaprogramming petri-net
Custom Java classloader not being used to load dependencies?

I've been trying to set up a custom classloader that intercepts classes to print out which classes are being loaded …

java class jvm metaprogramming classloader
Is there a way to do a C++ style compile-time assertion to determine machine's endianness?

I have some low level serialization code that is templated, and I need to know the system's endianness at compiletime …

c++ templates metaprogramming endianness
Getting a list of classes that include a module

I have a mixin for which I would like to get a list of all the classes that have included …

ruby module metaprogramming mixins
Can a line of Python code know its indentation nesting level?

From something like this: print(get_indentation_level()) print(get_indentation_level()) print(get_indentation_level()) I would like to …

python reflection metaprogramming indentation tokenize