
How to build Apache modules in Swift - helge5
https://github.com/AlwaysRightInstitute/mod_swift/blob/master/README.md
======
kinofcain
With regards to being able to call a Swift function from C, stevetrewick
pointed me to @_cdecl early last year[0][1][2]:

    
    
        @_cdecl("foobar") public func foobar() {}
    

I haven't yet used it in anger, but that will compile in Swift 3.

[0][https://news.ycombinator.com/item?id=11650628](https://news.ycombinator.com/item?id=11650628)

[1][https://github.com/apple/swift/commit/013aad13d4245a012cfb76...](https://github.com/apple/swift/commit/013aad13d4245a012cfb762b7edccf92013b3609)

[2][https://swiftlang.ng.bluemix.net/#/repl/d68be430e72609717f71...](https://swiftlang.ng.bluemix.net/#/repl/d68be430e72609717f718006aa0ae137eae872ca7a0b7e8141b351770b0c9eac)

~~~
xenadu02
Be careful; it currently relies on the Objecive-C runtime which is not present
on non-Apple platforms.

As the PR says, it also doesn't handle turning throwing functions into errors,
nor does it check for collisions.

Another thing you can do is declare a function pointer type in C and assign to
it from Swift by calling a C setter function (more or less a small
trampoline).

~~~
networked
>it currently relies on the Objecive-C runtime which is not present on non-
Apple platforms.

Maybe I misunderstand you, but this doesn't seem to be the case, at least not
in Swift 3.0-RELEASE. I was able to use @_cdecl for a callback in a Tcl
extension ([https://tcl.wiki/48057](https://tcl.wiki/48057)) on Linux.

~~~
ewmailing
I'm using @_cdecl on Android which doesn't have the the Obj-C runtime.

------
jimjag
Pretty cool stuff. Too bad it's not available under an Open Source license.
That kind of severely limits who can use it and what they can use it for. :-(

~~~
helge5
Maybe just ask if you want to actually use it for something (remember that it
is explicitly marked as a tech-demo, not as something you should use). I've
heard they are pretty forthcoming ... ;->

------
Sembiance
What do people still use Apache for? Hasn't everyone moved onto Nginx?

~~~
onion2k
Apache2 is still better for servers that host lots of small applications
(largely due to htaccess enabling "per directory" config). That's increasingly
unusual as people move to nginx in containers, but it does still happen.

~~~
citrusui
I know that YouTube runs (or previously ran) on lighttpd. Have there been any
major developments/improvements as of late?

