[Swift-devel] New built-in system, request for comments

Mihael Hategan hategan at mcs.anl.gov
Sat Apr 5 02:40:23 CDT 2014


It's possible. But there is no notion of input mapper. A mapper is an
isomorphism between a sub-set of the variable space and a sub-set of the
file name space. It goes both ways. So when a variable is declared with
a mapper, that mapper provides the information required to convert
between the variable/structure fields and the file system and/or back.

The basic advantage of that is that the "mapping" can be procedural, so
that would be efficient for arbitrarily large data structures, since it
would only require the algorithm to convert between a type path and a
fie name (or back).

That said, it's entirely possible to implement your example below, and
it might actually make things easier. Plus there are other limitations
that prevent us from having arbitrarily large data structures, so that
argument only goes so far.

Mihael

On Fri, 2014-04-04 at 20:18 -0500, Tim Armstrong wrote:
> I'm curious if there's a difference in Swift/K between how input mappers
> work and how function outputs work.  Ie. could you have an equivalent
> function system_map() like
> 
> file folder[];
> folder = system_map("find foo -type f");
> 
> 
> On Fri, Apr 4, 2014 at 5:47 PM, Mihael Hategan <hategan at mcs.anl.gov> wrote:
> 
> > I think that from a language design perspective there two important
> > questions to ask:
> >
> > 1. Can you reasonably achieve the same with existing swift features?
> > 2. Where else would system() be useful?
> >
> > Mihael
> >
> > On Fri, 2014-04-04 at 12:08 -0500, Yadu Nand wrote:
> > > Hi,
> > >
> > > I have just added a new builtin "system" to trunk. It takes a string,
> > > which is executed in the shell
> > > by java and the results are returned as an array. This is done to make
> > > mappings easier, for example,
> > > you can map an entire folder "foo" using the following :
> > >
> > > file folder[ ] < array_mapper; files = system ("find foo -type f") >;
> > >
> > > If the execution of the string provided fails, the logger would report
> > > the the exitcode and stderr to
> > > the swift stdout.
> > >
> > > Thanks,
> > > Yadu Nand B
> > > _______________________________________________
> > > Swift-devel mailing list
> > > Swift-devel at ci.uchicago.edu
> > > https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel
> >
> >
> > _______________________________________________
> > Swift-devel mailing list
> > Swift-devel at ci.uchicago.edu
> > https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-devel
> >





More information about the Swift-devel mailing list