<br><br><div class="gmail_quote">On Wed, Jul 6, 2011 at 8:28 PM, David T. Lewis <span dir="ltr">&lt;<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
On Wed, Jul 06, 2011 at 06:38:10PM -0700, Eliot Miranda wrote:<br>
&gt;<br>
&gt; On Wed, Jul 6, 2011 at 6:31 PM, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt;<br>
&gt; &gt; With a new version of plugin submitted by Eliot it no longer crashing :)<br>
&gt; &gt;<br>
&gt;<br>
&gt; Slang is occasionally super-tricky.  If you write<br>
&gt;<br>
&gt;     self atexit: #sendSignalToPids<br>
&gt;<br>
&gt; it generates<br>
&gt;<br>
&gt;     atexit(&quot;sendSignalToPids&quot;)<br>
&gt;<br>
&gt; which will crash.  You must write<br>
&gt;<br>
&gt;     self atexit: #sendSignalToPids asSymbol<br>
&gt;<br>
&gt; to get it to generate<br>
&gt;<br>
&gt;     atexit(sendSignalToPids)<br>
&gt;<br>
&gt; (where sendSignalToPids is some function to be called at exit).<br>
&gt;<br>
&gt; If course we should change this but there&#39;s backwards-compatibility for<br>
&gt; plugin to consider.  Does anyone depend on the old behavior?  I&#39;ve been<br>
&gt; bitten more than a few times by this.  Sigh...<br>
<br>
</div>Symbols and strings are used more or less interchangably in C translation<br>
(aka &quot;slang&quot;) and in pragmas. </blockquote><div><br></div><div>Not so.  Strings and symbols are only used interchangeably in type declarations and these can be put in pragmas.  So</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;var: #theFP type: #&#39;char *&#39;&gt;</div>
<div><br></div><div>is equivalent to</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;var: &#39;theFP&#39; type: &#39;char *&#39;&gt;</div><div><br></div><div>since Slang merely transcribes the characters in either the string or symbol.</div>
<div><br></div><div>But in code a symbol should be different to a string.  A string should translate to a string, and a symbol should translate to a name.  e.g. in </div><div><br></div><div>    self sizeof: #SQFile</div><div>
<br></div><div>it is really dumb of Slang to translate this as sizeof(&quot;SQFile&quot;).  Since we&#39;re always talking about literal symbols and literal strings it is always possible for the programmer to use a literal string where they mean there to be a string, and not a symbol.  Further, this change would not affect any of the existing uses of symbols and strings for type declarations.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">So I think that there is a general expectation<br>
that either a symbol or a string would translate to C as a string.</blockquote><div><br></div><div>I disagree.  Its a historical accident that we should agree to clean-up.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
 In<br>
the case of #sendSignalToPids, this is actually a function pointer that<br>
is being used in a rather specialized context.</blockquote><div><br></div><div>A context which arises throughout the VM with indirect function calls, with sizes of types, etc.  </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
 So even though the<br>
translation of &#39;self atexit: #sendSignalToPids&#39; produces a surprising<br>
result in this case, I would still say that is reasonable to expect<br>
Smalltalk symbols and strings to both translate into C strings, and<br>
it would not be reasonable to expect a simple C translator to do<br>
enough type checking to figure out that in this particular case the<br>
&#39;#sendSignalToPids&#39; should be treated as a function pointer rather<br>
than as a string.<br></blockquote><div><br></div><div>I disagree.  But I&#39;ve been using the #asSymbol workaround since I want consensus before making any change.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<br>
The original method in UnixOSProcessPlugin is written as follows in<br>
order to avoid this issue:<br>
<br>
        self cCode: &#39;atexit(sendSignalToPids)&#39;.<br></blockquote><div><br></div><div>This isn&#39;t a good approach since one can neither look for senders of #atexit: nor #sendSignalToPids, nor can one simulate its execution.  In general the use of a string argument to cCode: should be ruthlessly stamped out whereever possible.</div>
<div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
I also note that the purpose of SlangBrowser is to make it easy to<br>
review code like this while it is being written, so I guess that I<br>
should get off my butt and get this working in the oscog branch one<br>
of these days :-/<br>
<br>
Dave<br>
<br>
</blockquote></div><br><br clear="all"><br>-- <br>best,<div>Eliot</div><br>