Questions tagged [meta-programming]

Meta-programming is the writing of programs with the ability to treat programs as their data.

Meta-programming is the writing of computer programs with the ability to treat programs as their data. Such programs can be be designed to read, generate, analyze and/or transform other programs, and even modify itself while running. The language in which the meta-program is written is called the meta-language. The language of the programs that are manipulated is called the object language.

11 questions
29
votes
3 answers

What are staged functions (conceptually)?

In a recent CACM article [1], the authors present an implementation for staged functions. They use the term as if it was well-known, and none of the references looks like an obvious introduction. They give a short explanation (emphasis mine and…
Raphael
  • 73,212
  • 30
  • 182
  • 400
5
votes
1 answer

Implementing a Compiler with Macros

I've been thinking about embedded languages (domain-specific or otherwise), and in particular the approach where we define a datatype to represent terms of the embedded language, e.g. (in Haskell): data Expr = Numeral Int | Apply Expr…
Warbo
  • 642
  • 3
  • 13
5
votes
4 answers

Reviews of work in the field of partial evaluation (post 1993)

I'm looking for relatively new reviews of research work on partial evaluation. The most recent work I've found is "Tutorial notes on partial evaluation" by Charles Consel and Olivier Danvy (1993). The book Partial Evaluation and Automatic Program…
3
votes
2 answers

Is Terra the only system programming language able to compile code at runtime?

I stumbled across Terra last year, and the most similar language I can think of is Julia. Terra is inspired by and uses Lua for templating/metaprogramming instead of being derived from e.g. the Lisp or ML families, but like many JITted language…
2
votes
1 answer

Metaprogramming taken to an unnecessarily high level- how can a program write not just other programs, but a programming language?

So basically, automated language-oriented programming. I've tried finding info on this concept, but have had some trouble, probably because my brain is having a bit of trouble grasping the subject while thinking about it. It could be better defined…
1
vote
3 answers

Is it possible to define branches which, once taken once, will become the default forever?

Assuming I have a very simple branching: switch on var: 1 => branch1 2 => branch2 default => branch3 And I wish to implement a program that will forever take "branch2" when entering this sequence of instructions once branch2 is taken. This…
1
vote
1 answer

What is the motivation behind (purpose of) "macros" in languages such as Rust, Nim, Crystal, etc.?

Most constructs / schemes in programming serve an essential purpose (sometimes more than one), for instance : Structs in essentially C's solution to the problem of providing user defined data types. Classes in C, Python, generalize the concept and…
Serge Hulne
  • 165
  • 5
1
vote
2 answers

What is the best book on the theory of programing languages?

I want to learn programming. I have knowledge of mathematical logic. So, what I am searching is a book (or varios books) for learning to programming, but I think that a book like one which I imagine would be great. As I said, I have knowledge of…
1
vote
0 answers

Lambda calculus and runtime inspection of the term

This is possibly related to reflection and quoting but I don't want to assume anything beforehand. Here is my requirement. My typed lambda calculus (Curry style) is a simpler variant of Calculus of Constructions (CoC). Is it possible to write an…
1
vote
3 answers

Meta-computational complexity?

Computational complexity asks the following question: Given a problem $P$, what is the time-cost of the lowest time-cost machine $M^*$ that solves $P$? But this misses a certain aspect of the complexity of $P$, namely the complexity of finding $M^*$…
user56834
  • 4,244
  • 5
  • 21
  • 35
0
votes
1 answer

Is it possible to define a pairwise function that can either append to a tuple or make a tuple, potentially with nested tuples?

I lack the vocabulary to appropriately express the question succinctly, so I apologize if the title question is confusing. Suppose you can define a binary infix operator that produces tuples, and you want this operator to be able to…
Maindo
  • 3
  • 2