[Swift-devel] loops and strings

Mihael Hategan hategan at mcs.anl.gov
Fri Jul 27 10:46:06 CDT 2007


Variables in swift are single assignment. You can't assign to a variable
twice. What, in your opinion, should the error message be instead of the
current one?

On Fri, 2007-07-27 at 10:22 -0500, Veronika Nefedova wrote:
> I am not sure if its possible to do string operations inside the loop  
> in swift?
> I have a versy simple test code that doesn't work no matter what.  
> Obviously, I am missing something.
> This is the code:
> 
> file fls[]<filesys_mapper;pattern="*.prt",location=".">;
> string wham_string = "#";
> foreach prt_file in fls
> {
>        wham_string = @strcat (wham_string, ", wham");
>        print (wham_string);
> }
> print (wham_string);
> 
> 
> basically I expect to have this as an output:  
> #,wham,wham,wham,wham,... (its a test code (-;)
> 
> instead I have these errors:
> 
> wham_string is already assigned with a value of #
> wham_string is already assigned with a value of #
>          vdl:assign @ test.kml, line: 46
>          vdl:mains @ test.kml, line: 39
> Caused by: java.lang.IllegalArgumentException: wham_string is already  
> assigned with a value of #
>          at org.griphyn.vdl.mapping.AbstractDataNode.setValue 
> (AbstractDataNode.java:255)
>          at org.griphyn.vdl.karajan.lib.Assign.function(Assign.java:70)
> <snip>
> 
> 
> In any case -- if I can't construct the string by using the loop -  
> how else could it be done?
> 
> I use the constructed string then to map an array (I understand I  
> can't map individual array elements):
> 
> file whamfiles_$s[] <fixed_array_mapper;files="$wham_string">; //it  
> was in the wrapper script before)
> 
> 
> Nika
> 
> _______________________________________________
> Swift-devel mailing list
> Swift-devel at ci.uchicago.edu
> http://mail.ci.uchicago.edu/mailman/listinfo/swift-devel
> 




More information about the Swift-devel mailing list