[Swift-devel] readData2

Mihael Hategan hategan at mcs.anl.gov
Wed Jul 6 14:24:27 CDT 2011


On Wed, 2011-07-06 at 18:28 +0000, Ben Clifford wrote:
> 
> > > Swift already has a mechanism for specifying the type of a file. Its the 
> > > swift type system.
> > > 
> > >   CSVFile f <"myfile">;
> > >   foo = read(f);
> 
> > Noope! The structure of a given type is fixed. We want the ability to
> > read arbitrary such structures/types from a given format. Also for a
> > given type, there can be many formats. So the format is orthogonal to
> > the type.
> 
> CSVFile is a type that indicates that its file is "a csv file". Its not 
> the type of the return value (foo above), which is where the variable 
> structure occurs. Whether the file content matches the type of foo, beyond 
> being a CSV, is outside of the scope of the "this is a CSV file". That's 
> the same, I think, whether you use a mapped CSVFile, or whether you use a 
> string: its runtime-read-and-casting a loosely typed thing  (CSVFile or 
> string) into a specific data structure.

Ok, better. Sorry I didn't read the first email more carefully.

There's still some cognitive dissonance in my head though.

> 
> That reminds me of yet another way that was tossed about once: that the 
> mapping between file content and in-memory values should be done by a 
> mapper.

Right. A combination between mappers and read/writeData. Essentially
mappers were, in theory, more general, being able to use, for example, a
database. So their implementation was supposed to contain everything
necessary to make the actual storage transparent (and that included
reading actual data). readData is not portable outside files, or at
least not implicitly.




More information about the Swift-devel mailing list