Proposal: console input reader/handler in swift

Hello,

As you know lots of online coding challenge websites or University websites require to read data from console ( standard input ).

To read from console in Swift, you could use C "scanf" or "NSFileHandle.fileHandleWithStandardInput()". but I found them very Time and Code consuming. If you check the language popularity in these systems , most of them have simple functions to read from console ( C++ cin/cout , Java Scanner, Python raw_input ...etc ) . It is especially helpful when you have limited time. And it is not only the coding challenge websites, since Swift got open-source there will be lots of command line tools implemented in Swift.

I`d suggest to create very simple functionality to manage console input/output , it would make Swift language popular for solving online coding challenges and for command line tools.

Regards,

Sergo

IMHO, most default solutions to IO in other languages are gravely deficient and poorly handle error conditions (EOF, incorrect input type, etc), so I'm in favor of something better. However, the standard library only has basic types. Foundation has most of the rest of the standard things, but my understanding is the interfaces are not under community control.

There's certainly room for a community-maintained package for better file-based IO.

Félix

···

Le 25 déc. 2015 à 11:09:55, Sergo Beruashvili via swift-evolution <swift-evolution@swift.org> a écrit :

Hello,

As you know lots of online coding challenge websites or University websites require to read data from console ( standard input ).
To read from console in Swift, you could use C "scanf" or "NSFileHandle.fileHandleWithStandardInput()". but I found them very Time and Code consuming. If you check the language popularity in these systems , most of them have simple functions to read from console ( C++ cin/cout , Java Scanner, Python raw_input ...etc ) . It is especially helpful when you have limited time. And it is not only the coding challenge websites, since Swift got open-source there will be lots of command line tools implemented in Swift.

I`d suggest to create very simple functionality to manage console input/output , it would make Swift language popular for solving online coding challenges and for command line tools.

Regards,
Sergo
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

Hi Sergo,

isn't that what the function readLine(stripNewline:) in the standard library does?
https://developer.apple.com/library/ios/documentation/Swift/Reference/Swift_StandardLibrary_Functions/index.html#//apple_ref/swift/func/s:FSs8readLineFT12stripNewlineSb_GSqSS_

Alex

–––––
Alexander Kempgen
alex@kempgen.de

···

Am 25.12.2015 um 17:09 schrieb Sergo Beruashvili via swift-evolution <swift-evolution@swift.org>:

Hello,

As you know lots of online coding challenge websites or University websites require to read data from console ( standard input ).
To read from console in Swift, you could use C "scanf" or "NSFileHandle.fileHandleWithStandardInput()". but I found them very Time and Code consuming. If you check the language popularity in these systems , most of them have simple functions to read from console ( C++ cin/cout , Java Scanner, Python raw_input ...etc ) . It is especially helpful when you have limited time. And it is not only the coding challenge websites, since Swift got open-source there will be lots of command line tools implemented in Swift.

I`d suggest to create very simple functionality to manage console input/output , it would make Swift language popular for solving online coding challenges and for command line tools.

Regards,
Sergo
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

Yes, readLine is fine, but I think it might not be enough

···

________________________________
From: Alexander Kempgen <alex@kempgen.de>
Sent: Friday, December 25, 2015 8:42 PM
To: Sergo Beruashvili; swift-evolution
Subject: Re: [swift-evolution] Proposal: console input reader/handler in swift

Hi Sergo,

isn't that what the function readLine(stripNewline:) in the standard library does?
https://developer.apple.com/library/ios/documentation/Swift/Reference/Swift_StandardLibrary_Functions/index.html#//apple_ref/swift/func/s:FSs8readLineFT12stripNewlineSb_GSqSS_
Swift Standard Library Functions Reference<https://developer.apple.com/library/ios/documentation/Swift/Reference/Swift_StandardLibrary_Functions/index.html#//apple_ref/swift/func/s:FSs8readLineFT12stripNewlineSb_GSqSS_&gt;
developer.apple.com
Describes the Functions .

Alex

-----
Alexander Kempgen
alex@kempgen.de<mailto:alex@kempgen.de>

Am 25.12.2015 um 17:09 schrieb Sergo Beruashvili via swift-evolution <swift-evolution@swift.org<mailto:swift-evolution@swift.org>>:

Hello,

As you know lots of online coding challenge websites or University websites require to read data from console ( standard input ).
To read from console in Swift, you could use C "scanf" or "NSFileHandle.fileHandleWithStandardInput()". but I found them very Time and Code consuming. If you check the language popularity in these systems , most of them have simple functions to read from console ( C++ cin/cout , Java Scanner, Python raw_input ...etc ) . It is especially helpful when you have limited time. And it is not only the coding challenge websites, since Swift got open-source there will be lots of command line tools implemented in Swift.

I`d suggest to create very simple functionality to manage console input/output , it would make Swift language popular for solving online coding challenges and for command line tools.

Regards,
Sergo
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org<mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution