[Swift-devel] readData2

Ben Clifford benc at hawaga.org.uk
Wed Jul 6 12:41:45 CDT 2011


> Would it make sense to replace readData and readStructured with one flexible
> function which could use multiple formats? For example:
> 
> foo = read( -type="JSON", -file="myfile.json" );

Not that I particularly advocate doing things this way, but here's a 
different approach.

Swift already has a mechanism for specifying the type of a file. Its the 
swift type system.

  CSVFile f <"myfile">;
  foo = read(f);

That doesn't work so well if you want to specify lots of parameters to 
influence the reading, on the read line. But it does hark back to the 
beginning of swift where there was the idea of mapping data into XML.

Potentially you could define the parameterisation in the type, rather than 
in the read() call.

-- 



More information about the Swift-devel mailing list