<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Apologies: I broke mailing list rule #1: "dont use subject lines like&nbsp;Re: chuck-users Digest, Vol 28, Issue 23" &nbsp;My bad.</div><div><br class="webkit-block-placeholder"></div>HI. &nbsp;The function is a function. &nbsp;It is only a function and things within it (the string beep) are totally invisible to anything outside of the function definition. &nbsp;(That's only partly true as they&nbsp;theoretically&nbsp;could be passed by reference to something else, just ignore this fact for now.) &nbsp;'beep' does not belong to the sporked object. &nbsp;In fact, the name 'tester' isn't likely to be known to the sporked object.<div><br class="webkit-block-placeholder"></div><div>Chucks object and class capabilities are growing, but as they say on the street, they are not all 'that.' &nbsp;It has to do with inheritance, namespaces, run-time magic, and lots of stuff that would kill the real-time capability of a shred. &nbsp; All these are fun problems for a computer science person, but not so very fun if you just want to make chuck sing. &nbsp;I usually just pretend that sporked things are not objects at all.</div><div><br class="webkit-block-placeholder"></div><div>A shred is more like an independent agent: a baby. &nbsp;All it knows is the function that is used to give it birth. &nbsp;That function must know how to do all the communication to and from the outside environment. &nbsp;That function can call other functions (in other classes, possibly), look at global variables (in the same source file) and such.</div><div><br class="webkit-block-placeholder"></div><div>I'm sticking with global variables, at least for the short term. &nbsp;Programs in chuck are usually on the smallish side and a few global variables won't hurt the music and are just a necessary evil. &nbsp;I give those global variables useful names like "second_violin_bow_velocity" or some such and to keep track of them better.</div><div>&nbsp;&nbsp;&nbsp;<br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><div>Jim Hinds</div><div><a href="http://www.jahbini.org/">http://www.jahbini.org/</a></div><div><br class="khtml-block-placeholder"></div></div></span></div><div><blockquote type="cite"><br><br><div class="gmail_quote">On Nov 15, 2007 4:46 PM, Kassen &lt;<a href="mailto:signal.automatique@gmail.com" target="_blank">signal.automatique@gmail.com </a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Dear list,<br><br>Shreds are objects (of type Shred) and functions aren't objects. This is all good and well but it gets harder when we spork a function and the function becomes a Shred and hence a Object. Consider this; <br><br>------------------------<br>fun void tester()<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; "boom" =&gt; string beep;<br>&nbsp;&nbsp;&nbsp; while(1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;&lt;&lt;beep&gt;&gt;&gt;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; second =&gt; now;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;<br>spork ~ tester() @=&gt; Shred foo;<br>5::second =&gt; now;<br>&nbsp;&nbsp; &nbsp;<br>"clik" =&gt; foo.beep; //this doesn't work<br>&nbsp;&nbsp; &nbsp;<br>day=&gt; now;<br>---------------------------------------- <br> <br>It's not so clear to me *why* the offending line doesn't work. Maybe I'm misunderstanding something or making a syntax error but I think that what we are seeing here is a loss of namespace that would be useful and I don't understand why this happens. <br><br>I also tried stuff along these lines;<br><br>----------------------<br>class Bar extends Shred<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; //stuff including variables and a constructor<br>&nbsp;&nbsp;&nbsp; }<br>------------------------------<br><br>If I do that I can instantiate a "Bar" but all it does is run it's constructor; I can't manage to spork a Bar or assign a sporked shred to a Bar. I can also make a array of Bar's but all that gets me is the constructor running; <br><br>---------------------------<br>class Bar extends Shred<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; static int number;<br>&nbsp;&nbsp;&nbsp; &lt;&lt;&lt;number++&gt;&gt;&gt;;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>//print a series of numbers, no shreds in sight<br>&nbsp;Bar array[5]; <br>----------------------------------<br><br>So, now I'm quite happy I said so many times that there are no "stupid n00b questions" because now it's my turn to ask exactly what a "Shred" is because I'm starting to feel like I have no idea. :¬) <br><br>Could somebody please explain to me exactly what's going on here?<br><br><br>Yours,<br>Kas.<br> <br>_______________________________________________<br>chuck-users mailing list<br><a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.princeton.edu</a><br><a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank"> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br><br></blockquote></div><br> <br></blockquote></div><br></div></body></html>