<div dir="ltr">I agree that it is a no interface function call. Maybe this is also helpful with not needing to explicitly collect outputs to get staged out? My understanding is that If run.swift contains a bunch of nested loops, one would have declare a bunch of [auto] outputs and remember to append everything to them (or they could be considered tmps and not staged out). There's value to being forced to be thoughtful, but it might also be nice to start with the trailing import while prototyping/debugging a script and then switch to a wrapper after the dust has settled.<br><div><br></div><div>I'm focusing on direct staging, so the wrapper was straightforward. For reference:</div><div><a href="https://github.com/maxhutch/nek-swift/blob/alcf/debug.swift">https://github.com/maxhutch/nek-swift/blob/alcf/debug.swift</a><br></div><div><a href="https://github.com/maxhutch/nek-swift/blob/alcf/nek.swift">https://github.com/maxhutch/nek-swift/blob/alcf/nek.swift</a><br></div><div><br></div><div>If imports are only going to be supported in the preamble, could that be added to the docs?</div><div><a href="http://swift-lang.org/guides/trunk/userguide/userguide.html#_imports">http://swift-lang.org/guides/trunk/userguide/userguide.html#_imports</a><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jun 18, 2015 at 2:20 PM Mihael Hategan <<a href="mailto:hategan@mcs.anl.gov">hategan@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I don't think imports were meant to be used as a templating scheme,<br>
which is why they are restricted to be only at the start of a script.<br>
The alternative amounts to a dynamically scoped, no interface function<br>
call. So I don't think avoiding argument list bloat is a good enough<br>
reason to allow that, especially when you can package complex argument<br>
lists in a structure.<br>
<br>
Are the defs just values or do they also define behavior/functions?<br>
<br>
Mihael<br>
<br>
On Thu, 2015-06-18 at 18:18 +0000, Max Hutchinson wrote:<br>
> Not scattered; at the end. I will have ~10 use cases, each written as a<br>
> different defs file (i.e. defs_a.swift, defs_b.swift, etc). For each<br>
> use-case, the run.swift, which is a big foreach loop, is the same. Given<br>
> this structure, I can think of at least 4 organizations:<br>
> 1) run.swift imports "defs_a" or "defs_b". To change use cases, the<br>
> import in run.swift is edited. This is what I currently do but forces me<br>
> to either serialize inter-script execution or edit scripts that are in the<br>
> process of being executed.<br>
> 2) defs_a.swift, defs_b.swift, etc import "run". This seems clean and is<br>
> what I want to do.<br>
> 3) Wrapper scripts are created to contain both imports (i.e. a_wrap.swift<br>
> : ```import "defs_a"; import "run"```). This currently works, but results<br>
> in script bloat.<br>
> 4) Wrap the contents of run.swift in a procedure, import it at the top of<br>
> defs_{a,b,...}.swift, but then call it at the bottom. This is surely the<br>
> "right" way to do it, but its more effort and could have argument list<br>
> bloat.<br>
> Since each of these option is semantically identical, why not allow the<br>
> user to pick their preference?<br>
><br>
> On Thu, Jun 18, 2015 at 1:07 PM Mihael Hategan <<a href="mailto:hategan@mcs.anl.gov" target="_blank">hategan@mcs.anl.gov</a>> wrote:<br>
><br>
> > Yes, but I don't think it should.<br>
> ><br>
> > Why is it important to have import statements scattered through the<br>
> > script?<br>
> ><br>
> > Mihael<br>
> ><br>
> > On Thu, 2015-06-18 at 17:58 +0000, Max Hutchinson wrote:<br>
> > > Could that constraint be relaxed?<br>
> > ><br>
> > > On Thu, Jun 18, 2015 at 12:47 PM Mihael Hategan <<a href="mailto:hategan@mcs.anl.gov" target="_blank">hategan@mcs.anl.gov</a>><br>
> > wrote:<br>
> > ><br>
> > > > Hi,<br>
> > > ><br>
> > > > Yes. Imports must come before other types of statements.<br>
> > > ><br>
> > > > Mihael<br>
> > > ><br>
> > > > On Thu, 2015-06-18 at 17:20 +0000, Max Hutchinson wrote:<br>
> > > > > Do all import statements need to come before executable statements?<br>
> > > > ><br>
> > > > > I have two scripts: defs.swift and run.swift. If run.swift starts<br>
> > with<br>
> > > > > import "defs";<br>
> > > > > then everything works fine. If instead defs.swift ends with<br>
> > > > > import "run";<br>
> > > > > I get this error:<br>
> > > > > Swift trunk git-rev: 1d512cbda070d363e8ec3cf16e77dfcddc6e66cb<br>
> > > > heads/master<br>
> > > > > 6377<br>
> > > > > RunID: run011<br>
> > > > > Could not compile SwiftScript source: line 24:12: unexpected token: ;<br>
> > > > > where line 24 is:<br>
> > > > > int foo = 1;<br>
> > > > ><br>
> > > > > Thanks,<br>
> > > > > Max<br>
> > > > > _______________________________________________<br>
> > > > > Swift-user mailing list<br>
> > > > > <a href="mailto:Swift-user@ci.uchicago.edu" target="_blank">Swift-user@ci.uchicago.edu</a><br>
> > > > > <a href="https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user" rel="noreferrer" target="_blank">https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user</a><br>
> > > ><br>
> > > ><br>
> > > ><br>
> ><br>
> ><br>
> ><br>
<br>
<br>
</blockquote></div>