Quote:
|
Originally Posted by KickAssClown Are there any computer languages that have primitives, or objects which contain not a value, or address, but a expression of the written language itself? |
Some languages – especially interpreted (as opposed to compiled) one lend themselves better to what I thing you’re describing.
Though
LISP is usually mentioned as a language that lends itself to containing expressions of itself, I’m fond of
MUMPS (as anyone who’s noted the programs I’ve posted at hypography is likely aware

), which also lends itself to manipulating its own code.
Here’s a very simple example, cut from a MUMPS direct (interactive) mode terminal session (note the “USER>” is a typical direct mode prompt, not actual input or program output):
Code:
USER>r X
w 1 q:'5 s $p(X," ",3)="q:'"_($p(X,"'",2)-1) x X w 2
USER>x X
11111122222
USER>w X
w 1 q:'0 s $p(X," ",3)="q:'"_($p(X,"'",2)-1) x X w 2
USER>
This program counts down from 5 to 0. It’s not a particularly good or clever program, but remarkable in that the code contained in symbol X references no symbol but itself. Note that MUMPS keywords can be and usually are abbreviated (eg: r[ead] w[rite] q[uit] s[et] $p[iece] x[ecute]), leading many to comment that it looks like line noise.
It’s fairly easy to write much more complicated and meaningful self modifying MUMPS programs, such as in the puzzle game-playing program in my post
”Self modifying code in an interpreted language”.
__________________
Moderator: Computers and Technology; Medical Science; Science Projects and Homework; Philosophy of Science; Physics and Mathematics; Environmental Studies