I’d like to coin a term for an old but (to my knowledge) previously nameless idea.

When discussing the primitive constructs of a programming language, there is a litmus test for evaluating the quality of their design: can I implement a wrapper for the construct that looks and behaves exactly the same as the original, modulo the name? Passing this test is a good property for a language construct to have; it means the programmer has the power to substitute the construct with their own equally powerful ones.

Examples

Conditionals are a good motivating example. In Common Lisp, if is a special form that does what you expect:

But that doesn’t pass the test, because the usage is different from if ; you have to wrap the branches in Proc s. So if passes the pastiche test in Common Lisp, but not in Ruby. Looping constructs can be classified in the same way—can you mimic a for loop in your language?

Here’s another example. In Haskell, I can define a custom binary operator with the same “fixity” (precedence and associativity) as + :

But there is no way to implement map yourself in a type-safe way, because Go doesn’t have generics. In contrast, C++ has unordered_map , which is typically implemented in C++ itself. So Go’s map fails the pastiche test, but C++’s unordered_map passes.

Definition

Here is my attempt at a good definition for the term:

In a given language, a construct passes the pastiche test iff it is possible to define an extensionally identical construct in the language under a different name, optionally using the original construct in the implementation.

In this definition, “language” does not necessarily mean “programming language”—it could mean “domain-specific language”, “natural language”, or any kind of language in which it is possible to define abstractions.

“Extensionally identical” means the imitation construct is observably indistinguishable from the original in syntax, usage, behavior, asymptotic complexity, etc. To the user, only the name is different.

The “optionally using the original construct in the implementation” part means that a simple wrapper suffices. It is not necessary to implement the construct from scratch.

Related concepts

Here are some related ideas which already have names:

First-class citizen : This refers to the ability for an entity to be stored in variables, passed as an argument to functions, etc. For example, functions are first-class citizens in most modern programming languages. In some programming languages , types are also first-class citizens.

Reification : The act of exposing an abstract aspect of a system as a first-class citizen. For example, in homoiconic languages, the structure of a program is reified as an abstract syntax tree which can be manipulated by the program itself. In languages with eval , the interpreter or compiler itself is reified.