Re: [swift-users] Swift for students

2015-12-07 Thread Mosab Elagha via swift-users
> the Swift Guided Tour Playground is really nice. I imagine the instant feedback of the playground would be great for teaching. > Apart from this, if the students have access to OS X and Xcode, I would consider Playgrounds quite compelling. Playgrounds would definitely be great to have someone ge

Re: [swift-users] XCTest on Linux

2015-12-07 Thread Stepan Hruda via swift-users
Thank you, Mish. On Tue, Dec 8, 2015 at 12:37 AM Mish Awadah wrote: > Don’t use “swift” unless you want to run the REPL. Here’s how you should > build a package that runs tests: > > local@ubuntu:~/Documents$ mkdir XTest > local@ubuntu:~/Documents$ cd XTest/ > local@ubuntu:~/Documents/XTest$ touc

Re: [swift-users] XCTest on Linux

2015-12-07 Thread Mish Awadah via swift-users
Don’t use “swift” unless you want to run the REPL. Here’s how you should build a package that runs tests: local@ubuntu:~/Documents$ mkdir XTest local@ubuntu:~/Documents$ cd XTest/ local@ubuntu:~/Documents/XTest$ touch Package.swift local@ubuntu:~/Documents/XTest$ emacs -nw main.swift local@ubunt

[swift-users] Pure Swift, cross platform way to open, read/write files?

2015-12-07 Thread Greg Skluzacek via swift-users
Hi new to Swift and I am really excited that Apple has open sourced it! I use macs at home an Linux at work, so now I may actually be able to develop in one language on both platforms (and not use Java). That being said, is there a way open a file for either reading line by line and writing line b

Re: [swift-users] Fwd: Re: Binding Regular C Functions (Gtk, Cairo, etc.)

2015-12-07 Thread Gage Morgan via swift-users
Okay, thanks. I'll experiment tomorrow evening. Cheers,--MGage-- Sent from Outlook On Mon, Dec 7, 2015 at 7:39 PM -0800, "Gage Morgan" wrote: Okey, so I see what they're trying to say, but what about functions from C that actually take input? For example, in Cairo, cairo_move_to() woul

Re: [swift-users] Fwd: Re: Binding Regular C Functions (Gtk, Cairo, etc.)

2015-12-07 Thread Gage Morgan via swift-users
Okey, so I see what they're trying to say, but what about functions from C that actually take input? For example, in Cairo, cairo_move_to() would not make the cut on its own. Matter of fact, it would take a surface in the form of a pointer and an x and y value. So we would have cairo_surface_t *

Re: [swift-users] Binding Regular C Functions (Gtk, Cairo, etc.)

2015-12-07 Thread Kwame Bryan via swift-users
There’s also this video by chris eidhof https://realm.io/news/pragma-chris-eidhof-swift-c/ . This will help with seeing a live implementation. Kwame > On Dec 7, 2015, at 10:23 PM, David Turnbull via swift-users > wrote: > > I think you're

[swift-users] Fwd: Re: Binding Regular C Functions (Gtk, Cairo, etc.)

2015-12-07 Thread Gage Morgan via swift-users
_ From: Gage Morgan Sent: Monday, December 7, 2015 9:40 PM Subject: Re: [swift-users] Binding Regular C Functions (Gtk, Cairo, etc.) To: Mish Awadah I read that. What I want to know is how to bind the functions themselves after creating a system

[swift-users] Binding Regular C Functions (Gtk, Cairo, etc.)

2015-12-07 Thread Gage Morgan via swift-users
For any project: How is a C to Swift function binding created? I'd like to know how to import C functions to Swift. Once I can do this successfully, I'll be all set.  Sent from Outlook ___ swift-users mailing list swift-users@swift.org https://lists.sw

Re: [swift-users] Confusing doc re: metatype type, also doesn't compile on linux

2015-12-07 Thread Mish Awadah via swift-users
Could you please file a bug mentioning where the code example was taken from? Thanks, - mish > On Dec 7, 2015, at 5:11 PM, Karl Pickett via swift-users > wrote: > > This code example: > > if someInstance.dynamicType === someInstance.self { > print("The dynamic and static type of someInst

Re: [swift-users] Linux

2015-12-07 Thread Kwame Bryan via swift-users
Hi Ankit, you’ll need to follow the instructions @ https://swift.org/getting-started/#installing-swift and look into the Linux section. After you can compile a simple swift project. Look into the Swift Programming Guide. Good Luck Regards K

Re: [swift-users] Parameter Validation

2015-12-07 Thread Jens Alfke via swift-users
> On Dec 7, 2015, at 5:24 PM, David Hart wrote: > > You enable assertions for release builds then? It depends on the target. In a lot of app-level code it doesn’t make much difference to leave them in, while in lower-level performance-sensitive code it’s a big slowdown. (Back when I worked at

[swift-users] Linux

2015-12-07 Thread Ankit Raj via swift-users
Hello, M new to swift and want to learn swift on my linux. It would be great if anyone guide me how to learn swift on linux. Thanks ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

Re: [swift-users] Parameter Validation

2015-12-07 Thread Dmitri Gribenko via swift-users
precondition() is enabled for release builds. On Mon, Dec 7, 2015 at 5:24 PM, David Hart via swift-users < swift-users@swift.org> wrote: > You enable assertions for release builds then? Remember, I'm talking > specifically about library code: the same way that calling NSArray's > objectAtIndex th

Re: [swift-users] Swift for students

2015-12-07 Thread Roshan via swift-users
> > Some context - I am talking to a teacher here at the University of > Illinois about using Swift in some classes and she wanted to know if there > was something could convince her, and possible students, that Swift is a > great language to learn. > > Stanford has been running a iOS development c

Re: [swift-users] Swift for students

2015-12-07 Thread joe via swift-users
If the students have Macs, then the Swift Guided Tour Playground is really nice. I imagine the instant feedback of the playground would be great for teaching. https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.playground.zip > On Dec 7,

[swift-users] Confusing doc re: metatype type, also doesn't compile on linux

2015-12-07 Thread Karl Pickett via swift-users
This code example: if someInstance.dynamicType === someInstance.self { print("The dynamic and static type of someInstance are the same") } else { print("The dynamic and static type of someInstance are different") } // prints "The dynamic and static type of someInstance are different” Does

[swift-users] Swift for students

2015-12-07 Thread Mosab Elagha via swift-users
Hi everyone, I'm looking for some showcases that can help younger people (14 or so) get interested in Swift. I figured the App Store would probably be the best place to find things this but wanted to know if anyone had any other idea that could get someone interested in the *language*. For the sa

Re: [swift-users] Parameter Validation

2015-12-07 Thread Jens Alfke via swift-users
> On Dec 7, 2015, at 11:39 AM, Jan Neumüller via swift-users > wrote: > > I fail to see any overhead here. Its the absolute minimum to get checked > values. Anything less is not checking. There’s no overhead if the function already ‘throws’ / returns errors. But not all functions do that (an

Re: [swift-users] Ignore header file with module?

2015-12-07 Thread Harlan Haskins via swift-users
Is there a way I can tell this not to compile with the OS X SDK? The C library is responsible for including all the headers it needs. > On Dec 4, 2015, at 7:15 PM, Harlan Haskins wrote: > > So what happens is flipper.h declares a struct called `flash`. When I use > `swift build` to build that

Re: [swift-users] Failure to import SwiftShims at the REPL

2015-12-07 Thread Jason Dusek via swift-users
Thank you Dmitri -- following your instructions, I was finally able to complete the example at the REPL. On Sat, 5 Dec 2015 at 18:17 Dmitri Gribenko wrote: > On Sat, Dec 5, 2015 at 5:36 PM, Jason Dusek via swift-users > wrote: > > Hi List, > > > > On Ubuntu 14.04, trying out Swift from the REPL

Re: [swift-users] Linux - How to use C libs

2015-12-07 Thread Max Howell via swift-users
Indeed, this *should* work, and if we have to do some tricks to make it do so we’re happy to make the modifications, so please file a bug and we’ll look into it. Thanks. Max > On Dec 7, 2015, at 11:06 AM, Mish Awadah via swift-users > wrote: > > Please file a bug describing the situation and

Re: [swift-users] Parameter Validation

2015-12-07 Thread Jan Neumüller via swift-users
> On 07.12.2015, at 20:03, Jens Alfke wrote: > > >> On Dec 7, 2015, at 10:56 AM, Jan Neumüller via swift-users >> mailto:swift-users@swift.org>> wrote: >> >> But what overhead? As you know Swift has *NO* exceptions. It’s just syntax >> sugar for normale error values. > > Mostly the overhead

Re: [swift-users] Build swift from the source

2015-12-07 Thread Mish Awadah via swift-users
> On Dec 7, 2015, at 11:26 AM, inbox only via swift-users > wrote: > > I have a 2 questions: > 1. How do I build swift from the source ? The answer to this is in the README (https://github.com/apple/swift) > 2. How do I do the path thingie so I can run executable from the terminal > using ju

[swift-users] Build swift from the source

2015-12-07 Thread inbox only via swift-users
I have a 2 questions: 1. How do I build swift from the source ? 2. How do I do the path thingie so I can run executable from the terminal using just "swift" ? ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swif

Re: [swift-users] get input from playground

2015-12-07 Thread Rick Ballard via swift-users
Hi Bee, Swift.org downloadable toolchains don't work with Xcode Playgrounds; Playgrounds use the copy of Swift that ships with Xcode. Any questions you have about Playground usage are best asked at https://devforums.apple.com/community/tools/xcode/playgrounds. Thanks, - Rick > On Dec

Re: [swift-users] Issue while debugging code built by swift package manager

2015-12-07 Thread Mish Awadah via swift-users
Please file a bug and include all the steps you used to reproduce this, as well as the project you used. Thanks! - mish > On Dec 5, 2015, at 10:55 AM, Ankit Agarwal wrote: > > I am able to set breakpoints in lldb but always getting module errors > whenever trying to print anything. > SampleUs

Re: [swift-users] Defer Question

2015-12-07 Thread Joe Groff via swift-users
> On Dec 7, 2015, at 10:29 AM, Ezekiel Elin via swift-users > wrote: > > Is there any way for me to identify what value is/will be returned by the > function in a defer block > > here’s some example code > > func someFunction() -> Int { > defer { > //Can I get the "5" that I'm re

Re: [swift-users] Are structs really always pessimistically copied when calling funcs?

2015-12-07 Thread Joe Groff via swift-users
> On Dec 7, 2015, at 10:27 AM, Karl Pickett wrote: > > I created https://bugs.swift.org/browse/SR-110 > for the compiler. However, I also > think that the documentation needs an issue filed. (Where to do that at?) Thanks! > The current docs say struc

[swift-users] Defer Question

2015-12-07 Thread Ezekiel Elin via swift-users
Is there any way for me to identify what value is/will be returned by the function in a defer block here’s some example code func someFunction() -> Int { defer { //Can I get the "5" that I'm returning here? } return 5 } - Ezekiel

Re: [swift-users] Single Page HTML Book

2015-12-07 Thread Brian Lanier via swift-users
Hi Suminda, We don’t have any plans to make the book available as a single HTML page. You can, however, can view the book online in our developer library at https://developer.apple.com/library/. Here’s the latest public version of the book: https://developer.apple.com/library/ios/documentation

Re: [swift-users] Are structs really always pessimistically copied when calling funcs?

2015-12-07 Thread Karl Pickett via swift-users
I created https://bugs.swift.org/browse/SR-110 for the compiler. However, I also think that the documentation needs an issue filed. (Where to do that at?) The current docs say structs are always copied (the only exception being inout to memory variable optimization). That would make programmers

Re: [swift-users] Parameter Validation

2015-12-07 Thread Jens Alfke via swift-users
> On Dec 7, 2015, at 9:40 AM, Dmitri Gribenko wrote: > > There are > just two processes -- one is performing a trap, and another one is the > test harness that verifies that the other process terminated. Ah — I thought it was some type of in-process exception/signal handler. > What would you l

Re: [swift-users] Parameter Validation

2015-12-07 Thread Dmitri Gribenko via swift-users
On Mon, Dec 7, 2015 at 10:02 AM, Jens Alfke wrote: > > On Dec 7, 2015, at 9:40 AM, Dmitri Gribenko wrote: > > There are > just two processes -- one is performing a trap, and another one is the > test harness that verifies that the other process terminated. > > > Ah — I thought it was some type of

Re: [swift-users] Are structs really always pessimistically copied when calling funcs?

2015-12-07 Thread Joe Groff via swift-users
> On Dec 6, 2015, at 5:16 PM, Karl Pickett via swift-users > wrote: > > I have a struct and this code: > > func test() { > precondition(sizeof(Foo) == 128) > > let s = Foo() > for _ in 0..<100_000_000 { > doSomething(s) > } > } > > The asm (on LInux, with -O) is showi

Re: [swift-users] Parameter Validation

2015-12-07 Thread Dmitri Gribenko via swift-users
On Mon, Dec 7, 2015 at 9:25 AM, Jens Alfke wrote: > > On Dec 7, 2015, at 9:21 AM, Dmitri Gribenko wrote: > > Yes you can. Maybe not with the current XCTest, but there's nothing that > prevents unit-testing traps in principle. The standard library is already > doing that. See test/1_stdlib/Arra

Re: [swift-users] Parameter Validation

2015-12-07 Thread Jens Alfke via swift-users
> On Dec 7, 2015, at 9:21 AM, Dmitri Gribenko wrote: > > Yes you can. Maybe not with the current XCTest, but there's nothing that > prevents unit-testing traps in principle. The standard library is already > doing that. See test/1_stdlib/ArrayTraps.swift.gyb for some examples: Nice! But co

Re: [swift-users] Are structs really always pessimistically copied when calling funcs?

2015-12-07 Thread Jens Alfke via swift-users
> On Dec 6, 2015, at 5:16 PM, Karl Pickett via swift-users > wrote: > > When I use an inout param, that is 2x as fast and doesn't re-initialize each > time. However I don't see why passing something immutably wouldn't be as > fast. Huh. That’s especially weird since the semantics of inout a

[swift-users] Are structs really always pessimistically copied when calling funcs?

2015-12-07 Thread Karl Pickett via swift-users
I have a struct and this code: func test() { precondition(sizeof(Foo) == 128) let s = Foo() for _ in 0..<100_000_000 { doSomething(s) } } The asm (on LInux, with -O) is showing me that s is being re-initialized on every iteration of the loop. I was hoping that thanks to

Re: [swift-users] run a specific test file

2015-12-07 Thread Stephen Celis via swift-users
Hi, > On Dec 7, 2015, at 8:19 AM, Arsen Gasparyan via swift-users > wrote: > > Hello, > Is it possible to run a specific test file like in rspec: > > rspec path/to/spec/file.rb > > I have tried ./swift/utils/build-script -t > swift/test/decl/protocol/req/recursion.swift but it doesn't work

[swift-users] get input from playground

2015-12-07 Thread Bee via swift-users
Hi all, I'd like to read keyboard input from playground console. Swift doc gives me readLine function. I tried it on Playground but it didn't accept any input I entered from the keyboard. Screenshot attached. The code: // — start code — var name: String print("What's your name? ", terminator: "")