<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">On Aug 19, 2020, at 12:25 PM, Jack Atherton &lt;<a href="mailto:lja@ccrma.stanford.edu" class="">lja@ccrma.stanford.edu</a>&gt; wrote:<br class=""><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">The most straightforward version of an import statement would just add the public class in that file to the VM if it hasn't been added already. Do you think an import statement should also add the ability to splice in functions and other classes too?</div></div></div></blockquote><div><br class=""></div><div>In LiCK many public classes depend on non-public classes local to the file. &nbsp;A quick count shows 437 public classes of approximately 939 total classes:</div><div><br class=""></div><div>$ chuck import.ck</div><div>...</div><div>[chuck](VM): sporking incoming shred: 437 (RubberBand.ck)...<br class="">LiCK imported at path ~/working/lick/<br class=""><br class=""></div><div>$ find lick -name "*.ck" | xargs grep class | wc -l</div><div>&nbsp; &nbsp; 939</div><div><br class=""></div><div>Imports should also be recursive, e.g. the public class in the imported file may import other classes.</div><div><br class=""></div><div>Finally, as described in the linked issue below, having namespaces via a namespace or package statement would also be quite useful.</div><div><br class=""></div><div>Cheers,</div><div><br class=""></div><div>&nbsp; &nbsp;michael</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">I get an email when new pull requests are made, but I don't get the chance to look through them very often.</div><div class=""><br class=""></div><div class="">~Jack<br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Aug 15, 2020 at 9:31 PM Curtis Ullerich &lt;<a href="mailto:curtullerich@gmail.com" class="">curtullerich@gmail.com</a>&gt; wrote:<br class=""></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" class="">Makes sense; thank you for the details. A more restricted sense of importing than normal sporking might be good, like only&nbsp;allowing importing of class and method definitions. Pre-constructor class code makes that a little messier.<div class=""><br class=""></div><div class="">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 class=""><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" target="_blank" class="">lja@ccrma.stanford.edu</a>&gt; wrote:<br class=""></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" class=""><div class="">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're trying to use a class that'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't used in that file, so the type checker doesn't complain, then at runtime the first .add is run, followed by the second.</div><div class=""><br class=""></div><div class="">I guess a Machine.import would need to compile and run the file during compile time, which might be non-trivial because I'm not sure that the compiler can be gracefully interrupted. Maybe the "import" 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 class=""></div><div class=""><br class=""></div><div class="">I have definitely faced the same issue when I was working on utility classes.</div><div class=""><br class=""></div><div class="">~Jack<br class=""></div></div><br class=""><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" class="">curtullerich@gmail.com</a>&gt; wrote:<br class=""></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" class=""><div class="">Thanks for confirming. I subscribed to the issue in case it gains traction.<div dir="auto" class=""><br class=""></div><div dir="auto" class="">I found it curious that Machine.add used in the header of <a href="http://control.ck/" target="_blank" class="">control.ck</a> doesn't work, but it works if the libs and <a href="http://control.ck/" target="_blank" class="">control.ck</a> are Machine.added in the same file. Why is that?</div><br class=""><br class=""><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" class="">heuermh@gmail.com</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="">Hello Curtis,<div class=""><br class=""></div><div class="">In LiCK there is one big <a href="http://import.ck/" rel="noreferrer" target="_blank" class="">import.ck</a> file (your second method)</div><div class=""><br class=""></div><div class=""><a href="https://github.com/heuermh/lick/blob/master/import.ck" rel="noreferrer" target="_blank" class="">https://github.com/heuermh/lick/blob/master/import.ck</a></div><div class=""><br class=""></div><div class="">I typically use it with two terminal windows, in one</div><div class=""><br class=""></div><div class="">$ chuck --loop</div><div class=""><br class=""></div><div class="">and in the other</div><div class=""><br class=""></div><div class="">$ chuck + <a href="http://import.ck/" rel="noreferrer" target="_blank" class="">import.ck</a></div><div class="">$ chuck + <a href="http://other-stuff.ck/" rel="noreferrer" target="_blank" class="">other-stuff.ck</a></div><div class=""><br class=""></div><div class="">See also</div><div class=""><br class=""></div><div class="">Add namespaces and import statements</div><div class=""><a href="https://github.com/ccrma/chuck/issues/109" rel="noreferrer" target="_blank" class="">https://github.com/ccrma/chuck/issues/109</a></div><div class=""><br class=""></div><div class="">Cheers,</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp;michael</div><div class=""><br class=""></div><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Aug 8, 2020, at 12:56 PM, Curtis Ullerich &lt;<a href="mailto:curtullerich@gmail.com" rel="noreferrer" target="_blank" class="">curtullerich@gmail.com</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class="">What's the state of the art for imports/includes?<div class=""><br class=""></div><div class="">If I have files <a href="http://lib0.ck/" rel="noreferrer" target="_blank" class="">lib0.ck</a>&nbsp;and&nbsp;<a href="http://lib1.ck/" rel="noreferrer" target="_blank" class="">lib1.ck</a>&nbsp;that declare public classes both used in&nbsp;<a href="http://control.ck/" rel="noreferrer" target="_blank" class="">control.ck</a>, I understand these to be the two options for running them:</div><div class=""><br class=""></div><div class=""><font face="monospace" class="">chuck <a href="http://lib0.ck/" rel="noreferrer" target="_blank" class="">lib0.ck</a> <a href="http://lib1.ck/" rel="noreferrer" target="_blank" class="">lib1.ck</a> <a href="http://control.ck/" rel="noreferrer" target="_blank" class="">control.ck</a></font></div><div class=""><br class=""></div><div class="">or, make another file <a href="http://control-main.ck/" rel="noreferrer" target="_blank" class="">control-main.ck</a>:</div><div class=""><font face="monospace" class="">Machine.add("<a href="http://lib0.ck/" rel="noreferrer" target="_blank" class="">lib0.ck</a>");</font></div><div class=""><font face="monospace" class="">Machine.add("<a href="http://lib1.ck/" rel="noreferrer" target="_blank" class="">lib1.ck</a>");</font></div><div class=""><font face="monospace" class="">Machine.add("<a href="http://control.ck/" rel="noreferrer" target="_blank" class="">control.ck</a>");</font></div><div class=""><br class=""></div><div class="">and run it as:</div><div class=""><font face="monospace" class="">chuck <a href="http://control-main.ck/" rel="noreferrer" target="_blank" class="">control-main.ck</a></font></div><div class=""><br class=""></div><div class="">I thought it would work to use <font face="monospace" class="">Machine.add("<a href="http://lib0.ck/" rel="noreferrer" target="_blank" class="">lib0.ck</a>"); Machine.add("<a href="http://lib1.ck/" rel="noreferrer" target="_blank" class="">lib1.ck</a>");</font> as the first line of <a href="http://control.ck/" rel="noreferrer" target="_blank" class="">control.ck</a> and then just run <font face="monospace" class="">chuck <a href="http://control.ck/" rel="noreferrer" target="_blank" class="">control.ck</a>,</font> but the included classes are not found.&nbsp;</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">Thanks,</div><div class="">Curtis</div></div>
_______________________________________________<br class="">chuck-users mailing list<br class=""><a href="mailto:chuck-users@lists.cs.princeton.edu" rel="noreferrer" target="_blank" class="">chuck-users@lists.cs.princeton.edu</a><br class=""><a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer" target="_blank" class="">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br class=""></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">
chuck-users mailing list<br class="">
<a href="mailto:chuck-users@lists.cs.princeton.edu" rel="noreferrer" target="_blank" class="">chuck-users@lists.cs.princeton.edu</a><br class="">
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer noreferrer" target="_blank" class="">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br class="">
</blockquote></div></div></div>
_______________________________________________<br class="">
chuck-users mailing list<br class="">
<a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank" class="">chuck-users@lists.cs.princeton.edu</a><br class="">
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer" target="_blank" class="">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br class="">
</blockquote></div>
_______________________________________________<br class="">
chuck-users mailing list<br class="">
<a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank" class="">chuck-users@lists.cs.princeton.edu</a><br class="">
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer" target="_blank" class="">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br class="">
</blockquote></div>
_______________________________________________<br class="">
chuck-users mailing list<br class="">
<a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank" class="">chuck-users@lists.cs.princeton.edu</a><br class="">
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer" target="_blank" class="">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br class="">
</blockquote></div>
_______________________________________________<br class="">chuck-users mailing list<br class=""><a href="mailto:chuck-users@lists.cs.princeton.edu" class="">chuck-users@lists.cs.princeton.edu</a><br class="">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users<br class=""></div></blockquote></div><br class=""></body></html>