<div dir="ltr">Makes sense; thank you for the details. A more restricted sense of importing than normal sporking might be good, like only allowing importing of class and method definitions. Pre-constructor class code makes that a little messier.<div><br></div><div>By the way, does anyone get notified when new pull requests are made on the ChucK repo, or should I be tagging someone?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 14, 2020 at 9:01 AM Jack Atherton &lt;<a href="mailto:lja@ccrma.stanford.edu">lja@ccrma.stanford.edu</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I think this is an artifact of the type checker. It will run on a single file before any of the lines in the file are run. So, if you&#39;re trying to use a class that&#39;s only being imported with a Machine.add declaration, that declaration is not going to run before the type checker gets to the line where you use it. But, if a file has two Machine.add declarations, then the type isn&#39;t used in that file, so the type checker doesn&#39;t complain, then at runtime the first .add is run, followed by the second.</div><div><br></div><div>I guess a Machine.import would need to compile and run the file during compile time, which might be non-trivial because I&#39;m not sure that the compiler can be gracefully interrupted. Maybe the &quot;import&quot; keyword is the way to go. This might be straightforward to do by adding a few rules to the grammar and making import be a reserved word, and allow a number of import statements (only?) at the top of of a program.<br></div><div><br></div><div>I have definitely faced the same issue when I was working on utility classes.</div><div><br></div><div>~Jack<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Aug 8, 2020 at 11:46 AM Curtis Ullerich &lt;<a href="mailto:curtullerich@gmail.com" target="_blank">curtullerich@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div>Thanks for confirming. I subscribed to the issue in case it gains traction.<div dir="auto"><br></div><div dir="auto">I found it curious that Machine.add used in the header of <a href="http://control.ck" target="_blank">control.ck</a> doesn&#39;t work, but it works if the libs and <a href="http://control.ck" target="_blank">control.ck</a> are Machine.added in the same file. Why is that?</div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Aug 8, 2020, 11:35 Michael Heuer &lt;<a href="mailto:heuermh@gmail.com" target="_blank">heuermh@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Hello Curtis,<div><br></div><div>In LiCK there is one big <a href="http://import.ck" rel="noreferrer" target="_blank">import.ck</a> file (your second method)</div><div><br></div><div><a href="https://github.com/heuermh/lick/blob/master/import.ck" rel="noreferrer" target="_blank">https://github.com/heuermh/lick/blob/master/import.ck</a></div><div><br></div><div>I typically use it with two terminal windows, in one</div><div><br></div><div>$ chuck --loop</div><div><br></div><div>and in the other</div><div><br></div><div>$ chuck + <a href="http://import.ck" rel="noreferrer" target="_blank">import.ck</a></div><div>$ chuck + <a href="http://other-stuff.ck" rel="noreferrer" target="_blank">other-stuff.ck</a></div><div><br></div><div>See also</div><div><br></div><div>Add namespaces and import statements</div><div><a href="https://github.com/ccrma/chuck/issues/109" rel="noreferrer" target="_blank">https://github.com/ccrma/chuck/issues/109</a></div><div><br></div><div>Cheers,</div><div><br></div><div>   michael</div><div><br></div><div><div><br><blockquote type="cite"><div>On Aug 8, 2020, at 12:56 PM, Curtis Ullerich &lt;<a href="mailto:curtullerich@gmail.com" rel="noreferrer" target="_blank">curtullerich@gmail.com</a>&gt; wrote:</div><br><div><div dir="ltr">What&#39;s the state of the art for imports/includes?<div><br></div><div>If I have files <a href="http://lib0.ck/" rel="noreferrer" target="_blank">lib0.ck</a> and <a href="http://lib1.ck/" rel="noreferrer" target="_blank">lib1.ck</a> that declare public classes both used in <a href="http://control.ck/" rel="noreferrer" target="_blank">control.ck</a>, I understand these to be the two options for running them:</div><div><br></div><div><font face="monospace">chuck <a href="http://lib0.ck/" rel="noreferrer" target="_blank">lib0.ck</a> <a href="http://lib1.ck/" rel="noreferrer" target="_blank">lib1.ck</a> <a href="http://control.ck/" rel="noreferrer" target="_blank">control.ck</a></font></div><div><br></div><div>or, make another file <a href="http://control-main.ck/" rel="noreferrer" target="_blank">control-main.ck</a>:</div><div><font face="monospace">Machine.add(&quot;<a href="http://lib0.ck/" rel="noreferrer" target="_blank">lib0.ck</a>&quot;);</font></div><div><font face="monospace">Machine.add(&quot;<a href="http://lib1.ck/" rel="noreferrer" target="_blank">lib1.ck</a>&quot;);</font></div><div><font face="monospace">Machine.add(&quot;<a href="http://control.ck/" rel="noreferrer" target="_blank">control.ck</a>&quot;);</font></div><div><br></div><div>and run it as:</div><div><font face="monospace">chuck <a href="http://control-main.ck/" rel="noreferrer" target="_blank">control-main.ck</a></font></div><div><br></div><div>I thought it would work to use <font face="monospace">Machine.add(&quot;<a href="http://lib0.ck/" rel="noreferrer" target="_blank">lib0.ck</a>&quot;); Machine.add(&quot;<a href="http://lib1.ck/" rel="noreferrer" target="_blank">lib1.ck</a>&quot;);</font> as the first line of <a href="http://control.ck/" rel="noreferrer" target="_blank">control.ck</a> and then just run <font face="monospace">chuck <a href="http://control.ck/" rel="noreferrer" target="_blank">control.ck</a>,</font> but the included classes are not found. </div><div><br></div><div>Are these the two options, or is there another way that can support transitive inclusion (not having to list each util file for every program that uses them)?</div><div><br></div><div>Thanks,</div><div>Curtis</div></div>
_______________________________________________<br>chuck-users mailing list<br><a href="mailto:chuck-users@lists.cs.princeton.edu" rel="noreferrer" target="_blank">chuck-users@lists.cs.princeton.edu</a><br><a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br></div></blockquote></div><br></div></div>_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu" rel="noreferrer" target="_blank">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer noreferrer" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
</blockquote></div></div></div>
_______________________________________________<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" rel="noreferrer" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
</blockquote></div>
_______________________________________________<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" rel="noreferrer" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
</blockquote></div>