<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dw="https://www.dreamwidth.org">
  <id>tag:dreamwidth.org,2009-05-20:374172</id>
  <title>Rich and Strange Aeons</title>
  <subtitle>mindstalk</subtitle>
  <author>
    <name>mindstalk</name>
  </author>
  <link rel="alternate" type="text/html" href="https://mindstalk.dreamwidth.org/"/>
  <link rel="self" type="text/xml" href="https://mindstalk.dreamwidth.org/data/atom"/>
  <updated>2017-02-02T18:43:58Z</updated>
  <dw:journal username="mindstalk" type="personal"/>
  <entry>
    <id>tag:dreamwidth.org,2009-05-20:374172:465845</id>
    <link rel="alternate" type="text/html" href="https://mindstalk.dreamwidth.org/465845.html"/>
    <link rel="self" type="text/xml" href="https://mindstalk.dreamwidth.org/data/atom/?itemid=465845"/>
    <title>Shadows of JavaScript</title>
    <published>2017-02-02T18:43:58Z</published>
    <updated>2017-02-02T18:43:58Z</updated>
    <category term="programming"/>
    <category term="ocaml"/>
    <category term="javascript"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">Months ago, Robbie had found this scoping problem in Python, which I &lt;a href="http://mindstalk.dreamwidth.org/450941.html"&gt;reduced to essentials&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I'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("demo").innerHTML = g1;

  var g1 = 5;

}
func();
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;(I'm not including the HTML framework because DW/LJ would yell at me if I did.)&lt;br /&gt;&lt;br /&gt;Output is 'undefined', rather than 12.  As in Python, the local variable further down shadows the outer scope variable (doesn't matter if the "g1=12" has a 'var' 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't think I can even create similar code in Scheme/Lisp, where the scoping is explicit with parentheses.  (There's 'define' but I think that makes a new global, and it didn't work.)  In Ocaml I have&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
let g1="10";;

let func () =
  print_endline g1;
  let g1="cat" 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 "let ... in...".&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=mindstalk&amp;ditemid=465845" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2009-05-20:374172:461499</id>
    <link rel="alternate" type="text/html" href="https://mindstalk.dreamwidth.org/461499.html"/>
    <link rel="self" type="text/xml" href="https://mindstalk.dreamwidth.org/data/atom/?itemid=461499"/>
    <title>mysteries of TCO</title>
    <published>2016-12-11T20:36:06Z</published>
    <updated>2016-12-11T20:36:06Z</updated>
    <category term="ocaml"/>
    <category term="c++"/>
    <category term="programming"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">So I'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="cut-wrapper"&gt;&lt;span style="display: none;" id="span-cuttag___1" class="cuttag"&gt;&lt;/span&gt;&lt;b class="cut-open"&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class="cut-text"&gt;&lt;a href="https://mindstalk.dreamwidth.org/461499.html#cutid1"&gt;this got long&lt;/a&gt;&lt;/b&gt;&lt;b class="cut-close"&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style="display: none;" id="div-cuttag___1" aria-live="assertive"&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=mindstalk&amp;ditemid=461499" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
</feed>
