Re: [swift-users] Capturing references to initializers?

2015-12-10 Thread Pierre Monod-Broca via swift-users
Hi, I had the same problem with delegate methods (they all had the same prefix). I used lambda as a workaround, but I agree it is less elegant : let b: = { Foo(customNumber: $0) } let c: = { Foo(numberToInc: $0) } Pierre > Le 10 déc. 2015 à 23:41, Austin Zheng via swift-users > a écrit : >

[swift-users] Need Help with C-to-Swift (finally)

2015-12-10 Thread Gage Morgan via swift-users
So, if I had this code written in C: int main (int argc, char *argv[]) { cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80); cairo_t *cr = cairo_create (surface); cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT

[swift-users] Here's a multi-platform OpenGL loader for Swift.

2015-12-10 Thread David Turnbull via swift-users
If you tried using OpenGL with something other than Apple's framework then you probably didn't get very far. The header files of GLEW and Epoxy aren't fully understood by Swift. So I wrote some Swift code that generates some Swift code using the XML file from Khronos. Now everything you usually get

[swift-users] Cairo Compiles, Need to Translate to test

2015-12-10 Thread Gage Morgan via swift-users
Okay, so I have no idea what I did, but I got an executable. Now I need to translate to get a basic image.___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

Re: [swift-users] Recommendation for thread-safe dictionary

2015-12-10 Thread Howard Lovatt via swift-users
I would do something like: import Foundation class Task { // Must be a class to prevent Swift copy semantics eliminating the result private static let queue = dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_HIGH, 0) private let group = dispatch_group_create()

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Matthew Davies via swift-users
Okay I'll have to dig more into using that sort of syntax. And no problem ;) *Matthew Davies* Junior Developer, GeoStrategies Director of Photography, OffBlock Films 209-225-3246 <209-225.3246> | 209-202-3284 | daviesg...@gmail.com | daviesge

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Brent Royal-Gordon via swift-users
(Sorry for the repeat, Matthew.) > Can you clarify a bit on that? So, what you're saying is to generate routing > code based off the DSL router I've written? Yes, unless you can modify your DSL so you can directly provide your controller classes, you’ll probably need to generate code. By “prov

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Matthew Davies via swift-users
You're right. I should be using a class instead… *Matthew Davies* Junior Developer, GeoStrategies Director of Photography, OffBlock Films 209-225-3246 <209-225.3246> | 209-202-3284 | daviesg...@gmail.com | daviesgeek.com

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Daniel Dunbar via swift-users
> On Dec 10, 2015, at 1:01 PM, Matthew Davies via swift-users > wrote: > > Yes I have the protoco​l​, but the problem is that I would want to be able to > call a method on the class that isn't necessarily defined in the protocol. You should only call methods that are defined in the protocol,

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Matthew Davies via swift-users
I could do that, and that would work, but I figured out a way of doing this. import Foundation protocol Controller { init() } class Main : Controller { required init() {} func index() -> String { return "INDEX" } } let inst = Main() let method = Main.index method(inst) func run(ctrl: Controlle

Re: [swift-users] How to deploy swift app without a Mac

2015-12-10 Thread Mish Awadah via swift-users
No, you need Xcode to deploy to an iOS device. - mish > On Dec 10, 2015, at 2:23 PM, Andy via swift-users > wrote: > > I use Ubuntu to develop Swift apps. How can I test it? Can i deploy it to my > iphone to test without a Mac? > > Thanks > > >

Re: [swift-users] How to print formated "%.9f" Double? Swift 2.2 ?

2015-12-10 Thread Mish Awadah via swift-users
> On Dec 10, 2015, at 1:50 PM, Harlan Haskins via swift-users > wrote: > > I’m not sure what happened to String(format:), but I haven’t been able to get > it to work either. > It’s printing its argument as a tuple. I believe that String(format:) is implemented differently on Linux due to lack

[swift-users] Capturing references to initializers?

2015-12-10 Thread Austin Zheng via swift-users
Hello Swift users, I have a question about capturing references to initializers. You can do the following right now: struct Foo { let number : Int // This type has a single initializer init() { number = 10 } } let a = Foo.init // a's type: () -> Foo So far so good. Now

[swift-users] How to deploy swift app without a Mac

2015-12-10 Thread Andy via swift-users
I use Ubuntu to develop Swift apps. How can I test it?  Can i deploy it to my iphone to test without a Mac? Thanks ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

Re: [swift-users] How to print formated "%.9f" Double? Swift 2.2 ?

2015-12-10 Thread Isaac Gouy via swift-users
iirc I also tried to find a function that would round to 9 places, but this didn't seem to be available ? func round(value: Float, decimalPlaces: UInt) On Thursday, December 10, 2015 1:58 PM, Brent Royal-Gordon via swift-users wrote: >Variadic methods don't work on Linux yet: >https:/

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Matthew Davies via swift-users
Can you clarify a bit on that? So, what you're saying is to generate routing code based off the DSL router I've written? On Thu, Dec 10, 2015 at 13:52 Brent Royal-Gordon wrote: > For URL routing, I would currently suggest generating code at compile > time. Someday you might be able to replace thi

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Brent Royal-Gordon via swift-users
For URL routing, I would currently suggest generating code at compile time. Someday you might be able to replace this with a macro-based DSL, but for now, I don't see a better option. On the bright side, this does mean you'll have actual machine code doing your routing, which might be faster t

Re: [swift-users] How to print formated "%.9f" Double? Swift 2.2 ?

2015-12-10 Thread Johan Jensen via swift-users
He probably means Stack Overflow . On Thu, Dec 10, 2015 at 10:38 PM, Gage Morgan via swift-users < swift-users@swift.org> wrote: > You mean .so files? Yeah, Cairo does not work with it either. > > Sent from Outlook Mobile > > > > > On Thu, Dec 10

Re: [swift-users] How to print formated "%.9f" Double? Swift 2.2 ?

2015-12-10 Thread Gage Morgan via swift-users
You mean .so files? Yeah, Cairo does not work with it either. Sent from Outlook Mobile On Thu, Dec 10, 2015 at 12:41 PM -0800, "Isaac Gouy via swift-users" wrote: I've tried various things from SO but none of them seem to work with Swift 2.2 on Ubuntu. _

Re: [swift-users] Is there a way to @NoInline a func or method?

2015-12-10 Thread Karl Pickett via swift-users
Thanks. I filed a bug to have@inline documented. On Thu, Dec 10, 2015 at 12:04 PM, Mish Awadah wrote: > Maybe I don’t understand the depth of your question, but a cursory Google > search turns up this: > http://stackoverflow.com/questions/27881051/is-there-a-way-in-swift-to-declare-an-inline-fu

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Matthew Davies via swift-users
Yes I have the protoco ​l​ , but the problem is that I would want to be able to call a method on the class that isn't necessarily defined in the protocol. I.e., I would like to be able to do something like this ​:​ ​---​ protocol Controller { init() } class MainController : Controller {

[swift-users] How to print formated "%.9f" Double? Swift 2.2 ?

2015-12-10 Thread Isaac Gouy via swift-users
I've tried various things from SO but none of them seem to work with Swift 2.2 on Ubuntu. ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Matthew Davies via swift-users
I'm building a URL router in which I'd like to pass a controller and a method. I don't want to instantiate all the controllers up front and pass the methods in as closures, nor do I want old controller instances still kept around. If there's a better way, I'm definitely open to any suggestions. I'm

Re: [swift-users] Recommendation for thread-safe dictionary

2015-12-10 Thread Dmitri Gribenko via swift-users
On Thu, Dec 10, 2015 at 11:20 AM, Jens Alfke wrote: > All we’re saying is that a class like this isn’t commonly useful enough to go > into a library. And too easy to misuse if provided. Dmitri -- main(i,j){for(i=2;;i++){for(j=2;j*/ ___ swift-users m

Re: [swift-users] Recommendation for thread-safe dictionary

2015-12-10 Thread Jens Alfke via swift-users
> On Dec 10, 2015, at 10:06 AM, Pelaia II, Tom via swift-users > wrote: > > But isn’t that really a problem with that use case rather than the concurrent > dictionary itself? It’s a problem with _most_ use cases of a concurrent dictionary, unfortunately. The values in such a dictionary can b

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Dan Stenmark via swift-users
NSSelectorFromString() is still available in Swift, and you should be able to use the result of that in performSelector, though I’m hesitant to support this approach as it flies in the face of the safety Swift tries to enforce. I’m curious about your use case here; are you trying to create some

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Matthew Davies via swift-users
Ooh okay. I think that should work for my purposes. Thanks. Somewhat related to this, how would I then call a method dynamically on an instance of the class, after instantiating it? --- class Graph { func call(method: String) { // Something goes here } func redraw() -> String { ret

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Daniel Dunbar via swift-users
Note that you can define a protocol which will allow your framework to instantiate the type, and to call methods on instances of that type. If you can structure your code in this fashion, it can be very elegant in that it doesn't require factory functions and it is type safe. For example: -- s

Re: [swift-users] Recommendation for thread-safe dictionary

2015-12-10 Thread Dmitri Gribenko via swift-users
On Thu, Dec 10, 2015 at 10:06 AM, Pelaia II, Tom wrote: > But isn’t that really a problem with that use case rather than the > concurrent dictionary itself? There are a lot of bad things one can do with > almost any code. For example, one can naively use the standard library > dictionary in subtle

Re: [swift-users] REPL failed

2015-12-10 Thread Dmitri Gribenko via swift-users
On Thu, Dec 10, 2015 at 9:59 AM, Daniel Dunbar wrote: > Actually, I am retracting this suggestion in favor of what I think is a > better one: > > What if we change the build process to build up a "composed package" as part > of the regular build. We would clear this at the start of each build, a

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Matthew Davies via swift-users
I don't really like the idea of a factory function, but unfortunately that might be the only way to do it :( However, due to my specific use case, I don't think a factory function will work. I'm working on a framework that will need to both instantiate the class from a string (or class type) *and*

Re: [swift-users] Is there a way to @NoInline a func or method?

2015-12-10 Thread Mish Awadah via swift-users
Maybe I don’t understand the depth of your question, but a cursory Google search turns up this: http://stackoverflow.com/questions/27881051/is-there-a-way-in-swift-to-declare-an-inline-function - mish > On Dec 10, 2015, at 8:23 AM, Karl Pickett via swift-users > wrote: > > Two use cases: >

Re: [swift-users] Recommendation for thread-safe dictionary

2015-12-10 Thread Dmitri Gribenko via swift-users
On Thu, Dec 10, 2015 at 9:24 AM, Pelaia II, Tom via swift-users < swift-users@swift.org> wrote: > /* provide subscript accessors */ > subscript(key: KeyType) -> ValueType? { > get { > var value : ValueType? > dispatch_sync(self.queue) { () -> Void in > value = self.internalDictionary[key] > } > re

Re: [swift-users] Dynamic linker DT_RPATH

2015-12-10 Thread Joe Groff via swift-users
> On Dec 10, 2015, at 1:43 AM, Ugo Arangino wrote: > >> On 05.12.2015, at 16:13, Joe Groff > > wrote: >> >>> >>> On Dec 4, 2015, at 8:49 PM, Daniel Dunbar >> > wrote: >>> >>> On Dec 4, 2015, at 6:37 PM, Ugo Arangino >>>

Re: [swift-users] Text editor

2015-12-10 Thread Jan Neumüller via swift-users
> On 10.12.2015, at 18:30, Daniel Dunbar wrote: > > There are a wide variety of workflows in the world, some people really enjoy > working in the terminal, others don't. > > Please be mindful of our Code of Conduct: > https://swift.org/community/#code-of-conduct >

Re: [swift-users] Text editor

2015-12-10 Thread Daniel Dunbar via swift-users
There are a wide variety of workflows in the world, some people really enjoy working in the terminal, others don't. Please be mindful of our Code of Conduct: https://swift.org/community/#code-of-conduct and that we want to be open and tolerant of everyones working preferences. - Daniel > On

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Jan Neumüller via swift-users
Please no factory madness in Swift. This stuff is bad enough in Java - don’t infect Swift with it. Jan > On 10.12.2015, at 18:23, Jens Alfke via swift-users > wrote: > > >> On Dec 10, 2015, at 7:26 AM, Harlan Haskins via swift-users >> mailto:swift-users@swift.org>> wrote: >> >> IIRC this

Re: [swift-users] Recommendation for thread-safe dictionary

2015-12-10 Thread Jens Alfke via swift-users
> On Dec 10, 2015, at 9:18 AM, Lane Schwartz via swift-users > wrote: > > I'm writing some code where I'd like multiple threads to be writing to a > common dictionary object. > Is there a recommended mechanism for doing this? Wrap mutexes* around dictionary accesses. If you have a lot more re

Re: [swift-users] Dynamic linker DT_RPATH

2015-12-10 Thread Dmitri Gribenko via swift-users
On Thu, Dec 10, 2015 at 1:43 AM, Ugo Arangino via swift-users < swift-users@swift.org> wrote: > > An other solution would be, to offer `.deb` packages for `libswiftCore.so` > ... > So other packages can have `libswiftCore.so` ... as package dependency. > In addition to this the Swift compiler can

Re: [swift-users] Recommendation for thread-safe dictionary

2015-12-10 Thread Pelaia II, Tom via swift-users
I have one that I created for Swift on OS X which uses libdispatch to protect access to the underlying data: /* dictionary that allows thread safe concurrent access */ final class ConcurrentDictionary : NSObject, SequenceType, DictionaryLiteralConvertible { /* internal dictionary */ private var

Re: [swift-users] Text editor

2015-12-10 Thread Jan Neumüller via swift-users
Sounds terrible annoying to work with. I don’t get why open source Swift means getting dirty in the lands of the disgusting terminal with make and other 60ties tools 8( Jan > On 10.12.2015, at 18:11, Harlan Haskins via swift-users > wrote: > > https://github.com/harlanhaskins/swift#developin

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Jens Alfke via swift-users
> On Dec 10, 2015, at 7:26 AM, Harlan Haskins via swift-users > wrote: > > IIRC this isn’t possible because there’s no Runtime to query for classnames > (it’s inherently unsafe anyway). It’s not unsafe if you specify a base class/protocol that the loaded class must conform to. > You might w

[swift-users] Recommendation for thread-safe dictionary

2015-12-10 Thread Lane Schwartz via swift-users
Hi, I'm writing some code where I'd like multiple threads to be writing to a common dictionary object. Is there a recommended mechanism for doing this? Thanks, Lane ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/list

Re: [swift-users] Text editor

2015-12-10 Thread Harlan Haskins via swift-users
https://github.com/harlanhaskins/swift#developing-swift-in-xcode > On Dec 10, 2015, at 12:10 PM, Stephen Celis wrote: > > Is there an Xcode project file that makes building/debugging easier? > > Stephen > > On Thu, Dec 10, 2015 at 11:55 AM, Harlan Haskins via swift-users > mailto:swift-users@

Re: [swift-users] Text editor

2015-12-10 Thread Stephen Celis via swift-users
Is there an Xcode project file that makes building/debugging easier? Stephen On Thu, Dec 10, 2015 at 11:55 AM, Harlan Haskins via swift-users < swift-users@swift.org> wrote: > Lots of the Swift team uses Xcode, but the Swift repo has handy vim > bindings: > https://github.com/apple/swift/tree/ma

Re: [swift-users] REPL failed

2015-12-10 Thread Daniel Dunbar via swift-users
Dmitri, this seems to be a common problem. What would you think about creating symlinks in the build tree (when building the appropriate projects), just to smooth over the development process? - Daniel > On Dec 6, 2015, at 12:14 AM, Dmitri Gribenko via swift-users > wrote: > > On Sun, Dec 6

Re: [swift-users] REPL failed

2015-12-10 Thread Lane Schwartz via swift-users
I also hit this problem. I compiled like so: ./swift/utils/build-script --lldb I created a new directory to house the symlinks: $ mkdir mybins; cd mybins I created symlinks: $ for i in $(ls -1 ../build/Ninja-DebugAssert/llvm-linux-x86_64/bin/*); do ln -s $i; done $ for i in $(ls -1 ../build/Ni

Re: [swift-users] Dynamic linker DT_RPATH

2015-12-10 Thread Joe Groff via swift-users
> On Dec 10, 2015, at 1:43 AM, Ugo Arangino wrote: > >> On 05.12.2015, at 16:13, Joe Groff > > wrote: >> >>> >>> On Dec 4, 2015, at 8:49 PM, Daniel Dunbar >> > wrote: >>> >>> On Dec 4, 2015, at 6:37 PM, Ugo Arangino >>>

Re: [swift-users] Python problem when compiling lldb

2015-12-10 Thread Lane Schwartz via swift-users
Thanks, Markus. I'll keep tabs on that bug as well. On Thu, Dec 10, 2015 at 9:32 AM, Markus Trippelsdorf wrote: > On 2015.12.10 at 09:29 -0600, Lane Schwartz via swift-users wrote: > > I'm still working on getting a clean compile on Scientific Linux 7.1. So > > for I've gotten a compile (after a

Re: [swift-users] Text editor

2015-12-10 Thread Johan Jensen via swift-users
I think they use all of those. They have already shared some of their dotfiles on GitHub: https://github.com/apple/swift/tree/master/utils/vim https://github.com/apple/swift/blob/master/utils/swift-mode.el https://github.com/apple/swift/blob/master/utils/sil-mode.el —Johan On Thu, Dec 10, 2015 a

[swift-users] Logo on swift.org

2015-12-10 Thread Kilian Koeltzsch via swift-users
Hi all, this is probably not the ideal place for this request, but it'd be awesome if someone with the necessary access and files could update https://swift.org/assets/images/swift.svg to remove a small error on the right side of the Swift icon. This is how it currently looks: https://twitter.com

[swift-users] Python problem when compiling lldb

2015-12-10 Thread Lane Schwartz via swift-users
Hi, I'm still working on getting a clean compile on Scientific Linux 7.1. So for I've gotten a compile (after applying Pull Request #282) when for the basic build script with no additional flags (./swift/utils/build-script). I'm now trying to also compile with lldb (./swift/utils/build-script --l

Re: [swift-users] Instantiate Swift class from string

2015-12-10 Thread Harlan Haskins via swift-users
IIRC this isn’t possible because there’s no Runtime to query for classnames (it’s inherently unsafe anyway). You might want to look into a better way of doing that you’re trying to do. — Harlan > On Dec 10, 2015, at 12:42 AM, Matthew Davies via swift-users > wrote: > > I am using the Swift b

[swift-users] Text editor

2015-12-10 Thread Arsen Gasparyan via swift-users
Hello, Which text editor does the core team use? Vim or Emacs or Xcode. If so can you share your dotfiles. Regards, Arsen ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

Re: [swift-users] Dynamic linker DT_RPATH

2015-12-10 Thread Ugo Arangino via swift-users
> On 05.12.2015, at 16:13, Joe Groff wrote: > >> >> On Dec 4, 2015, at 8:49 PM, Daniel Dunbar wrote: >> >> >>> On Dec 4, 2015, at 6:37 PM, Ugo Arangino wrote: >>> >>> Why is the Dynamic linker DT_RPATH set, instead of configure it like this >>> `/etc/ld.so.conf.d/swift.conf` or copying the