<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description></description><title>code.diiq</title><generator>Tumblr (3.0; @diiqcode)</generator><link>http://code.diiq.org/</link><item><title>Leaking II</title><description>&lt;p&gt;Kartik Agaram pointed out that I haven&amp;#8217;t mentioned what happens during the assignment of pre-declared variables in scope.&lt;/p&gt;

&lt;p&gt;Here are a few scenarios. This first example signals an error, because a has no binding when &lt;code&gt;print a&lt;/code&gt; is called:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def foo (b):
   a ← b

foo 15
print a
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This example prints 15:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;a ← 5
def foo (b):
   a ← b

foo 15
print a
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Which seems acceptable &amp;#8212;- but this also prints 15:
&lt;!-- more --&gt;
    def foo (b):
       a ← b&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;a ← 5
foo 15
print a
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is a behavior that, while not inconsistent or incomprehensible, does prevent the encapsulation of arbitrary code in a scope. I have decided that I want to hold to this maxim:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Any arbitrary call made inside an otherwise empty procedure should have no side effects lasting beyond the end of the wrapping procedure.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Which is to say:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def foo ():
    (some-function)

(foo)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;must not change the global scope. This isn&amp;#8217;t the case for any lisp that I know of &amp;#8212;- it would cause significant problems:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;(define (inc-er)
    (let (a 0)
        (lambda () (set! a (+ a 1)))))
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Tricks like this counter would no longer work &amp;#8212;- the &lt;code&gt;set!&lt;/code&gt; called (in an otherwise empty lambda) could have no effect on the value of &lt;code&gt;a&lt;/code&gt;. (And even if you allow it to affect its own personal &lt;code&gt;a&lt;/code&gt;, there are many reasons to have multiple functions all using the same closed values. It&amp;#8217;s a common lisp pattern.) Lisp survives by having both &lt;code&gt;let&lt;/code&gt; (no side effects) and &lt;code&gt;set&lt;/code&gt; (side effects as discussed above).&lt;/p&gt;

&lt;p&gt;I want to eliminate &lt;code&gt;let&lt;/code&gt; from my language&amp;#8217;s vocabulary &amp;#8212;- it causes unnecessary proliferation of indentation and the creation of scopes without semantic meaning. The &lt;code&gt;let&lt;/code&gt; in &lt;code&gt;inc-er&lt;/code&gt; causes a scope to be created, by way of function call, but that function has no meaningful purpose except to mark the time during which &lt;code&gt;a&lt;/code&gt; exists. Procedures should be created based on what they do and what they return, not merely to piggy-back on their scope.&lt;/p&gt;

&lt;p&gt;So, there must be some way to declare that you intend to let some side effects escape from a procedure. My current intention is to use &lt;code&gt;leak&lt;/code&gt; to do so:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def inc-er ():
    a ← 0
    λ(): 
        leak a
        a ← a + 1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That is: assignment has NO effect outside the current scope unless the particular symbol being assigned has previously been leaked from that scope.&lt;/p&gt;

&lt;p&gt;This is NOT a delightful solution &amp;#8212;- it is longer and less pleasant than the scheme version, and leak would rapidly become repetitive to write; repetition is what we have computers for. There is no clear way to abstract &lt;code&gt;leak&lt;/code&gt; using f-exprs; currently Oyster doesn&amp;#8217;t use true macros. So I am unsure if this is a final answer, but it does satisfy my maxim while still entertaining the closure-magic that makes scheme so pleasurable.&lt;/p&gt;</description><link>http://code.diiq.org/post/11395426514</link><guid>http://code.diiq.org/post/11395426514</guid><pubDate>Sat, 08 Oct 2011 10:00:00 -0400</pubDate></item><item><title>Leaking I</title><description>&lt;p&gt;I&amp;#8217;m designing a programming language called &lt;a href="https://github.com/diiq/Tainted-Oyster"&gt;Tainted Oyster&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;One thing I have to think about is how to set a variable in the current scope. The easy way is the straightforward way:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;a ← 25
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This pairs the value 25 with the symbol &lt;code&gt;a&lt;/code&gt;, in the scope in which it&amp;#8217;s written. (The cheap way to say that is, &amp;#8220;Now &lt;code&gt;a&lt;/code&gt; is 25.&amp;#8221; Unfortunately, I&amp;#8217;m kinda slow, and when I&amp;#8217;m directly discussing the value bound to the same symbol in different scopes, little lies like &amp;#8220;is&amp;#8221; often trap me.)&lt;/p&gt;

&lt;p&gt;But I want to be able to abstract-ify assignment; for instance, in writing the procedure &lt;code&gt;def&lt;/code&gt;. &lt;code&gt;def&lt;/code&gt; creates a function and assigns it to a symbol in the current scope:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def fib (val):
    if (val &amp;lt;= 0):
        1
        val + fib (val - 1)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;For the moment, though, let me stick to a simpler example. Here&amp;#8217;s the skeleton of a function that tries to set &lt;code&gt;a&lt;/code&gt; to 5 times a number:&lt;!-- more --&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def set-a-to-5-times (b):
    # do some things

set-a-to-5-times 6
# now a == 30
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;What should go in the place of the comment &lt;code&gt;do some things&lt;/code&gt;? There are two possibilities that I have experienced. Some languages work this way: if the symbol you are assigning has not already been declared in the current scope, then it will be assigned in the global scope. Javascript works this way. This, I will put forward, is balderdash. It is foul because it prevents you from wrapping an unknown block of code in a scope in order to isolate it.&lt;/p&gt;

&lt;p&gt;The other option is that you can only set variables inside the current scope. This is a neat, functional approach, that is easy to reason about &amp;#8212;&amp;#8212; but it lacks the power to write &lt;code&gt;set-a-to-5-times&lt;/code&gt; at all.&lt;/p&gt;

&lt;p&gt;Oyster takes this tack: normally, scopes encapsulate completely &amp;#8212;- like the second option. But scopes can have holes explicitly poked in them. I call a hole a &amp;#8220;leak&amp;#8221;, and use a procedure called &lt;code&gt;leak&lt;/code&gt;. &lt;code&gt;leak&lt;/code&gt; with one argument does just what I need:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def set-a-to-5-times (b):
    leak a
    a ← 5 * b

set-a-to-5-times 6
print a                  # prints 30
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here, leak pokes an a-shaped hole in foo’s scope, and lets the assignment act as if it were one level up. Without leak, the print statement would signal an error, due to an unbound symbol a.&lt;/p&gt;

&lt;p&gt;That&amp;#8217;s leaking (with one argument).&lt;/p&gt;</description><link>http://code.diiq.org/post/11395443106</link><guid>http://code.diiq.org/post/11395443106</guid><pubDate>Thu, 06 Oct 2011 21:26:00 -0400</pubDate></item><item><title>Programmers think differently than non-programmers.</title><description>&lt;p&gt;or&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Singers think differently than non-singers&lt;/strong&gt;&lt;/p&gt;



&lt;p&gt;or&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Stuffed animal enthusiasts think differently than non-enthusiasts&lt;/strong&gt;&lt;/p&gt;



&lt;p&gt;Jacques Mattehij wrote a post [&lt;a href="http://jacquesmattheij.com/Programmers+think+differently+than+non-programmers+"&gt;here&lt;/a&gt;] about the way programmers think. He argues that programmers are analytical, but so are scientists; programmers are logical, but so are mathematicians; programmers are obsessive, but so are artists (he says scientists again, but I like this example better). &lt;/p&gt;



&lt;p&gt;Anyone can learn to program, Jacques points out, so programmers are surely not &lt;em&gt;born&lt;/em&gt; thinking differently than the rest of the world. I completely agree.&lt;/p&gt;



&lt;p&gt;Therefore, he concludes, programmers think no differently than non-programmers. That&amp;#8217;s absurd.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;His unstated assumption, I suspect, is that you will always think the way you thought when you were born. Thank god that is not true; babies are selfish, boring little bastards that think you disappear when you&amp;#8217;re behind a blanket. &lt;em&gt;Learning &lt;/em&gt;to program changes the way you think, along with learning Italian, learning to draw, and learning to figure skate. That&amp;#8217;s what learning is: a change in the way you think and behave.&lt;/p&gt;



&lt;p&gt;I am an artist and a programmer. Other artists have said to me in aggravation, &amp;#8220;It&amp;#8217;s a canvas, not a computer. It doesn&amp;#8217;t have to make sense.&amp;#8221; I continue to paint using the cognitive tools programming has given me; I suspect the other artists are wrong. Those artists are &lt;em&gt;capable&lt;/em&gt; of logical thought. It would be silly to think otherwise. The way they think about logic &lt;em&gt;is&lt;/em&gt; different however, as are the times they decide to use it consciously.&lt;/p&gt;



&lt;p&gt;Similarly, I program slowly, because I am obsessive about the aesthetics of my code. &amp;#8220;Just make it work,&amp;#8221; other coders say, and I try to speed up &amp;#8212; but I yearn for the same feeling of intuitive &amp;#8216;rightness&amp;#8217; from my code as from my art. Those other programmers are capable of recognizing beauty, but they strive for beauty at different times and in different ways.&lt;/p&gt;



&lt;p&gt;I would be a different person, and a different artist, if I did not program. &lt;/p&gt;



&lt;p&gt;I would be a different person, and a different programmer, if I did not make art.&lt;/p&gt;



&lt;p&gt;The habits, analogies, and problem-solving strategies of different fields are &lt;em&gt;different&lt;/em&gt;. That should not be a surprise. They sometimes overlap, and the more you learn, the more your mental tools leak from one field to another &amp;#8212; and that is a good thing.&lt;/p&gt;



&lt;p&gt;This is the obvious corollary to Sapir-Whorf: learning &lt;em&gt;anything&lt;/em&gt; changes the way you think.&lt;/p&gt;</description><link>http://code.diiq.org/post/11397380413</link><guid>http://code.diiq.org/post/11397380413</guid><pubDate>Sat, 15 Jan 2011 12:26:00 -0500</pubDate></item><item><title>WhiteProxy</title><description>&lt;p&gt;I get distracted very easily, and when I am looking up something important, I don&amp;#8217;t like spending my willpower avoiding distractions: facebook, my email, comics, youtube, twitter &amp;#8212;&amp;#8212; all the ten-thousand things. &lt;/p&gt;



&lt;p&gt;What could I do? I wrote a little proxy server that block all content unrelated to the task at hand. It even takes the time to look up related words, so that it won&amp;#8217;t block anything important. It also only gives me ten minutes of access &amp;#8212;- plenty of time to open some documentation, not enough time to open 50 tabs of vaguely related journal articles.&lt;/p&gt;



&lt;p&gt;I don&amp;#8217;t recommend using this all the time &amp;#8212;- sometimes free association hyperlinking is very valuable &amp;#8212;- but when the job needs doing, I don&amp;#8217;t need distracting. So I threw together &lt;a href="https://github.com/diiq/WhiteProxy"&gt;WhiteProxy&lt;/a&gt;.&lt;/p&gt;</description><link>http://code.diiq.org/post/11397396932</link><guid>http://code.diiq.org/post/11397396932</guid><pubDate>Thu, 13 Jan 2011 23:22:00 -0500</pubDate></item></channel></rss>

