Saturday, January 08, 2022

Code as Data

Code as data - Wikipedia

code and data allows computers to treat instructions in a programming language as data handled by a running program

Homoiconicity - Wikipedia

In computer programminghomoiconicity (from the Greek words homo- meaning "the same" and icon meaning "representation") is a property of some programming languages. A language is homoiconic if a program written in it can be manipulated as data using the language, and thus the program's internal representation can be inferred just by reading the program itself. This property is often summarized by saying that the language treats "code as data".

A commonly cited example is Lisp, which was created to allow for easy list manipulations and where the structure is given by S-expressions that take the form of nested lists, and can be manipulated by other Lisp code.[1] Other examples are the programming languages Clojure (a contemporary dialect of Lisp), Rebol (also its successor Red), RefalProlog, and more recently Julia

Lisp data, a list using different data types: (sub)lists, symbols, strings and integer numbers.

((:name "john" :age 20) (:name "mary" :age 18) (:name "alice" :age 22))

Lisp code. The example uses lists, symbols and numbers.

(* (sin 1.1) (cos 2.03))      ; in infix: sin(1.1)*cos(2.03)

Homoiconic Languages

Examples (in alphabetical order):

Language-oriented programming - Wikipedia

Language-oriented programming (LOP)[1] is a software-development paradigm where "language" is a software building block with the same status as objects, modules and components,[2] and rather than solving problems in general-purpose programming languages, the programmer creates one or more domain-specific languages for the problem first, and solves the problem in those languages.

Symbolic programming - Wikipedia

symbolic programming is a programming paradigm in which the program can manipulate its own formulas and program components as if they were plain data.

No comments: