{"id":1533,"date":"2011-09-20T16:00:44","date_gmt":"2011-09-20T23:00:44","guid":{"rendered":"https:\/\/www.reenigne.org\/blog\/?p=1533"},"modified":"2011-08-29T13:16:47","modified_gmt":"2011-08-29T20:16:47","slug":"language-in-which-assignment-is-reflective","status":"publish","type":"post","link":"https:\/\/www.reenigne.org\/blog\/language-in-which-assignment-is-reflective\/","title":{"rendered":"Language in which assignment is reflective"},"content":{"rendered":"<p>Sometimes I like to think about the most fundamental assumptions I can about how things work and wonder &#8220;what if this were not true&#8221;? Here is an example of that sort of crazy thinking.<\/p>\n<p>In most programming languages the statement &#8220;a=b&#8221; assigns the value of &#8220;b&#8221; to the variable named &#8220;a&#8221; &#8211; the two things &#8220;a&#8221; and &#8220;b&#8221; play completely different roles (although after the statement has executed they both have the same value). What if assignment instead were reflective, so that &#8220;a=b&#8221; meant the same thing as &#8220;b=a&#8221;?<\/p>\n<p>In that case, the information about whether this statement says something about &#8220;a&#8221; or something about &#8220;b&#8221; must come from elsewhere. For example, if earlier we had said &#8220;a=1&#8221; then both &#8220;a=b&#8221; and &#8220;b=a&#8221; would mean &#8220;b=1&#8221;. So each variable would have some information associated with it (let&#8217;s call it the &#8220;direction&#8221;) that says whether it accepts values from other variables or passes its value to other variables when assigned.<\/p>\n<p>If the direction of variables can change over the course of a program&#8217;s run, it won&#8217;t generally be possible to determine statically that two output variables are never assigned to each other, so that would have to become a run-time error. Unless we have the ability to change the direction of two connected variables at the same time, we&#8217;d have to allow two input variables to be assigned to each other (and give them both some default value).<\/p>\n<p>Perhaps surprisingly, you can end up with a Turing-complete language by going down this route &#8211; all you need are two other elements: one is a way of connecting three variables together (obviously no two of them could be outputs at the same time) and a NAND or NOR operator with two inputs and an output. Then you can build any function like a logic circuit.<\/p>\n<p>What&#8217;s the use of this? Well, it&#8217;s handy for describing electronic circuits (where assignment means connection). Also, when I write my <a href=\"https:\/\/www.reenigne.org\/blog\/modular-emulator\">modular emulator<\/a> it will have a language like this built in for describing how things are connected up. For that the &#8220;two outputs connected together&#8221; isn&#8217;t just a theoretical problem any more &#8211; the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Commodore_PET\">Commodore PET<\/a> computer had a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Killer_poke\">Killer poke<\/a> which connected two outputs together, damaging circuitry. An emulator could have some fun with how it handled this &#8211; I&#8217;m thinking an &#8220;explosion&#8221; graphical effect might be a nice easter egg.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes I like to think about the most fundamental assumptions I can about how things work and wonder &#8220;what if this were not true&#8221;? Here is an example of that sort of crazy thinking. In most programming languages the statement &#8220;a=b&#8221; assigns the value of &#8220;b&#8221; to the variable named &#8220;a&#8221; &#8211; the two things [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1533","post","type-post","status-publish","format-standard","hentry","category-computer"],"_links":{"self":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/1533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/comments?post=1533"}],"version-history":[{"count":3,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/1533\/revisions"}],"predecessor-version":[{"id":1535,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/1533\/revisions\/1535"}],"wp:attachment":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/media?parent=1533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/categories?post=1533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/tags?post=1533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}