[Swift-user] question about SwiftScript

Ben Clifford benc at hawaga.org.uk
Tue Sep 18 11:57:46 CDT 2007


I would expect you to have some problems there with some stuff that we 
haven't documented properly with regard to 'closing data sets'.

Basically: 

> (file all[]) appl_n (int j)
> {
>  if (j == 0) {
>    all[0] = gen0();
>  } else {
>    int k = j - 1;
>    all = appl_n (k);
>    all[j] = genn(all[k]);
>  }
> }

when appl_n returns, you can no longer assign anything more to all.

So you might get problems here:

>    all = appl_n (k);
>    all[j] = genn(all[k]);

because you've assign a value to all in the first line and are now no 
longer allowed to change it.

I just added some docs this morning about something that might do 
something similar to what you are trying to do, which is the iterate 
language feature.

Look at this chapter:

http://www.ci.uchicago.edu/swift/guides/tutorial.php#tutorial.iterate

on the 'sequential interation construct'.

I think that corresponds roughly with what you are trying to do, but does 
it in an iterative style rather than a recursive style.

(if you want to use this, grab the latest from SVN because I only just 
committed it and you'd be the first user of this...)

-- 



More information about the Swift-user mailing list