Code as data

Source: Wikipedia, the free encyclopedia.

In computer science, the expression code as data refers to the idea that

S-expressions as their main syntax, as writing programs using nested lists of symbols makes the interpretation of the program as an AST quite transparent (a property known as homoiconicity).[2][3]

These ideas are generally used in the context of what is called

reflection API that exposes the structure of a program as an object within the language, reducing the possibility of creating a malformed program.[7]

In

Kleene's second recursion theorem provides a form of code-is-data, by proving that a program can have access to its own source code.[8]

Code-as-data is also a principle of the

stored programs and data are both represented as bits in the same memory device.[4] This architecture offers the ability to write self-modifying code.[citation needed] It also opens the security risk of disguising a malicious program as user data and then using an exploit to direct execution to the malicious program.[9]

Data as Code

In

Configuration scripts, domain-specific languages and markup languages are cases where program execution is controlled by data elements that are not clearly sequences of commands.[10][11]

References

  1. ^ a b Poletto, Massimiliano A. (September 1999). Language and compiler support for dynamic code generation (PDF) (PhD). MIT. p. 20. until it is dynamically compiled, dynamic code is data. Similarly, lists in Lisp and strings in Perl are data, but they can be evaluated as code
  2. ^ Plusch, Mike (February 2004). "ConciseXML builds upon the important qualities of XML and S-Expressions". XML Journal. 5 (2). Gale Academic OneFile: 20+. Retrieved 14 January 2023. S-Expressions, or symbolic expressions, is the syntax behind Lisp-like languages, including Scheme. Basically, S-Expressions are nested lists of symbols. S-Expressions are used with languages that support the notion that code is data.
  3. S2CID 11111101
    . The Lisp and Scheme communities are an exception, since they tend to hold closely to the idea that code is data, and implement a large portion of their language in a smaller core language.
  4. ^ .
  5. .
  6. .
  7. .
  8. ^ Panangaden, Prakash. "Notes on the recursion theorem" (PDF). COMP 330 Theory of Computation. McGill University. Retrieved 15 January 2023.
  9. ^ Bohme, Rainer; Moore, Tyler (26 August 2013). "A Brief Introduction to Information Security" (PDF).
  10. ^ https://arxiv.org/abs/2401.10603
  11. ^ https://github.com/shuttle-hq/synth