[swift-evolution] Run Swift code at compile time

Alejandro Martinez alexito4 at gmail.com
Tue Dec 8 14:01:24 CST 2015


Hi everyone, 

Don't take this mail as an oficial proposal but just as some food for thought, I wanted to talk about this to see what you think about it.

I've been following the list since the "Open Source Day" and I've seen in many instances proposals that could have been solved by a macro system, being just a temporal solution since everything can't be done just now or being a permanent solution if that macro system existed. Some of them may include the thread about "code smells", automatic wrapper synthesis or deriving, or even the topic about forwarding calls automatically to an inner object.

My thinking was how difficult or viable it would be to run Swift code from our programs at compile time. I'm not experienced enough on computer languages to see it. The first time that I saw this was in a video from Jonathan Blow (https://www.youtube.com/watch?v=UTqZNujQOlA) and it looked like a really good idea. It would be much better that force people to learn another language (the macro language) or any other kind of preprocessor, instead you could use all your knowledge but just at compile time. It can also have good usages apart form generating code, but generating data that can be generated and known at compile time. And allow even to improve the usage of the language (maybe DSL) at a library level. 

Blow seems like is going one step further and allowing the program to call the compiler as if it was a library and even he talks about allowing it to modify the AST, which is maybe going a little to far away.

Anyway, that's the idea. Obviously is not something to be done in the near future. 

And sorry if it doesn't make any sense and I'm just making you lose your time.

Cheers, 

Alejandro Martínez
@alexito4
http://alejandromp.com





More information about the swift-evolution mailing list