<?xml version='1.0' encoding='utf-8' ?>

<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>Rich and Strange Aeons</title>
  <link>https://mindstalk.dreamwidth.org/</link>
  <description>Rich and Strange Aeons - Dreamwidth Studios</description>
  <lastBuildDate>Thu, 02 Feb 2017 18:43:58 GMT</lastBuildDate>
  <generator>LiveJournal / Dreamwidth Studios</generator>
  <lj:journal>mindstalk</lj:journal>
  <lj:journaltype>personal</lj:journaltype>
  <image>
    <url>https://v2.dreamwidth.org/241388/374172</url>
    <title>Rich and Strange Aeons</title>
    <link>https://mindstalk.dreamwidth.org/</link>
    <width>100</width>
    <height>75</height>
  </image>

<item>
  <guid isPermaLink='true'>https://mindstalk.dreamwidth.org/465845.html</guid>
  <pubDate>Thu, 02 Feb 2017 18:43:58 GMT</pubDate>
  <title>Shadows of JavaScript</title>
  <link>https://mindstalk.dreamwidth.org/465845.html</link>
  <description>Months ago, Robbie had found this scoping problem in Python, which I &lt;a href=&quot;http://mindstalk.dreamwidth.org/450941.html&quot;&gt;reduced to essentials&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I&apos;ve started finally learning JavaScript, and it has nicer lambdas than Python, and proper hiding of nested functions unlike Perl.  But it has the same scope problem:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
g1 = 12;
function func() {
  document.getElementById(&quot;demo&quot;).innerHTML = g1;

  var g1 = 5;

}
func();
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;(I&apos;m not including the HTML framework because DW/LJ would yell at me if I did.)&lt;br /&gt;&lt;br /&gt;Output is &apos;undefined&apos;, rather than 12.  As in Python, the local variable further down shadows the outer scope variable (doesn&apos;t matter if the &quot;g1=12&quot; has a &apos;var&apos; before it) even for lines before the local variable.&lt;br /&gt;&lt;br /&gt;As mentioned before, Perl has proper lexical scoping here (though not for nested functions.)  I don&apos;t think I can even create similar code in Scheme/Lisp, where the scoping is explicit with parentheses.  (There&apos;s &apos;define&apos; but I think that makes a new global, and it didn&apos;t work.)  In Ocaml I have&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
let g1=&quot;10&quot;;;

let func () =
  print_endline g1;
  let g1=&quot;cat&quot; in
    g1
  ;;

func();;
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Which I suspect is as explicit as Lisp parentheses, in its own way; the print line is obviously outside the following &quot;let ... in...&quot;.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=mindstalk&amp;ditemid=465845&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://mindstalk.dreamwidth.org/465845.html</comments>
  <category>programming</category>
  <category>ocaml</category>
  <category>javascript</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://mindstalk.dreamwidth.org/461499.html</guid>
  <pubDate>Sun, 11 Dec 2016 20:36:06 GMT</pubDate>
  <title>mysteries of TCO</title>
  <link>https://mindstalk.dreamwidth.org/461499.html</link>
  <description>So I&apos;ve learned that gcc/g++ do tail call optimization with the -O2 option; supposedly MS Visual Studio and clang do it when they can as well.  I have tested this:&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cut-wrapper&quot;&gt;&lt;span style=&quot;display: none;&quot; id=&quot;span-cuttag___1&quot; class=&quot;cuttag&quot;&gt;&lt;/span&gt;&lt;b class=&quot;cut-open&quot;&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class=&quot;cut-text&quot;&gt;&lt;a href=&quot;https://mindstalk.dreamwidth.org/461499.html#cutid1&quot;&gt;this got long&lt;/a&gt;&lt;/b&gt;&lt;b class=&quot;cut-close&quot;&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style=&quot;display: none;&quot; id=&quot;div-cuttag___1&quot; aria-live=&quot;assertive&quot;&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=mindstalk&amp;ditemid=461499&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://mindstalk.dreamwidth.org/461499.html</comments>
  <category>programming</category>
  <category>c++</category>
  <category>ocaml</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
</channel>
</rss>
