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

Michael Wilde wilde at anl.gov
Sat Apr 5 10:56:45 CDT 2014


On 4/4/14, 5:47 PM, Mihael Hategan 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?
No, not "reasonably". We do this to date by calling sh as an app. You 
need to obtain the cwd first, then pass that to the app to get it to cd 
to the swift working dir.  All told, a lot of code and cognitive 
dissonance for a simple task.
> 2. Where else would system() be useful?
Whenever a Swift script needs to perform shell-like operations relative 
to its current environment. Same reason C and virtually every other 
language provides a system( ) function.  Eg, directory setup, cleanup, etc.

But yes, a driving motivation here was to separate the task of finding 
the set of files that to be mapped from the semantics of mapping, and to 
provide the arbitrary flexibility to filter such lists that is often 
needed. And which should not in my opinion be hardwired into mappers.

I feel that Swift users would be best served by a very simple set of 
minimal mapping constructs, that would be used with powerful flexible 
functions like system( ) and glob( ) to let users do anything they would 
need or imagine.

- Mike





More information about the Swift-devel mailing list