This is an old revision of the document!


Lab 06: Design by Introspection

Over the years, a few programming paradigms have been successful enough to enter the casual vocabulary of software engineers: procedural, imperative, object-oriented, functional, generic, declarative. There's a B-list, too, that includes paradigms such as logic, constraint-oriented, and symbolic. The point is, there aren't very many of them altogether.

Design by Introspection is a proposed programming paradigm that is at the same time explosively productive and firmly removed from any of the paradigms considered canon. The tenets of Design by Introspection are:

  1. The rule of optionality: Component primitives are almost entirely opt-in. A given component is required to implement only a modicum of primitives, and all others are optional. The component is free to implement any subset of the optional primitives.
  2. The rule of introspection: A component user employs introspection on the component to implement its own functionality using the primitives offered by the component.
  3. The rule of elastic composition: A component obtained by composing several other components offers capabilities in proportion with the capabilities offered by its individual components.

static if

Let's start with a small refresher.

Templates are the feature that allows describing the code as a pattern, for the compiler to generate program code automatically. Parts of the source code may be left to the compiler to be filled in until that part is actually used in the program. Templates are very useful especially in libraries because they enable writing generic algorithms and data structures, instead of tying them to specific types.

static if is the compile time equivalent of the if statement. Just like the if statement, static if takes a logical expression and evaluates it. Unlike the if statement, static if is not about execution flow; rather, it determines whether a piece of code should be included in the program or not. The logical expression must be evaluable at compile time. If the logical expression evaluates to true, the code inside the static if gets compiled. If the condition is false, the code is not included in the program as if it has never been written.

traits

Named constraints

dss/laboratoare/06.1561972225.txt.gz ยท Last modified: 2019/07/01 12:10 by eduard.staniloiu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0