[Swift-devel] mapping and primitive types

Ben Clifford benc at hawaga.org.uk
Sun Jul 8 00:56:21 CDT 2007


The runtime has the concept of 'primitive' types - these are types such as 
int, float, string.

If a type is primitive, it is not staged in or out during procedure 
execution. This is (I think) the only difference in behaviour.

However, this isn't implemented particularly nicely.

If I run program A below, with the output mapped like this:

   messagefile outfile <"055-pass-int.out">;

then I get output in a file called 055-pass-int.out.

However, if I run program B below, which is similar but declares its 
output like this:

   int outfile <"056-pass-int.out">;

then the output file is not staged back, but no error is given suggesting 
that it is unwise to map an integer to a file.

I see why that is in the implementation, but its not pleasing from a user 
perspective.

Should it be possible to map a 'primitive' type?

If yes, then the below two programs should work.

If no, then program B should produce a sensible error message.

I think the answer should be 'yes' - there seems to be a long term desire 
to be able to access mapped data in the language (for example, to run a 
program to determine if an iterative process has converged, outputting a 
boolean, and use that boolean as a condition in a loop).


PROGRAM A
=========

type messagefile {}

(messagefile t) greeting(string m, int i) { 
    app {
        echo i stdout=@filename(t);
    }
}

messagefile outfile <"055-pass-int.out">;

int luftballons;

luftballons = 99;

outfile = greeting("hi", luftballons);


PROGRAM B
=========

(int t) greeting(string m, int i) { 
    app {
        echo i stdout=@filename(t);
    }
}

int outfile <"056-pass-int.out">;

int luftballons;

luftballons = 99;

outfile = greeting("hi", luftballons);


-- 



More information about the Swift-devel mailing list