Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2016-01-04 Thread Drew Crawford via swift-evolution
The swift package manager is currently considering its own define , so it's now the second official project that could benefit from this syntax. David, any interest in writing this up? > On Jan 3, 2016, at 4:48 AM,

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2016-01-04 Thread David Owens II via swift-evolution
I could (assuming I’m the David you’re referring to), though it will probably be towards the end of the week or early next week before I get a chance to get to it. -David > On Jan 4, 2016, at 1:03 PM, Drew Crawford wrote: > > The swift package manager is currently

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2016-01-04 Thread David Farler via swift-evolution
We already have @- and #-prefixed availability-like constructs, so I would prefer something more specific to the task – I wouldn't want to dilute the meaning of a package name argument by supplying it with the magic package "swift", for example. Changes to the language can be highly disruptive

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2016-01-04 Thread David Owens II via swift-evolution
The @available() and if #available constructs are not sufficient as they fall under the same limitations that your proposal addresses: they require that the non-valid branch not be parsed. For example, an API that has changes with a new language feature, such as variadic generic arguments,

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2016-01-03 Thread Goffredo Marocchi via swift-evolution
+1 from me as well, supporting conditional compilation when the two versions of foundation differ and may differ for the foreseeable future seems a must on this end. Sent from my iPhone > On 3 Jan 2016, at 10:12, Drew Crawford via swift-evolution > wrote: > >> If

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2016-01-03 Thread Drew Crawford via swift-evolution
> If we are going to support something like this, I’d rather see it be > something everyone could leverage as there are many use cases for this > feature: > > #if available("package-name", "1.2.*") > #endif Big +1. I've asked specifically to get some kind of conditional compilation on

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-20 Thread James Campbell via swift-evolution
Also in future versions features may go away meaning older libraries may assume that greater than swift 2 is all that is needed to imply compatibility. Also libraries may be written against features they may not know which version of swift it will get into. Additionally certain features aren't

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-20 Thread James Campbell via swift-evolution
I think we should be moving towards feature detection over swift version detection Sent from my iPhone > On 20 Dec 2015, at 06:32, Dirk Schreib via swift-evolution > wrote: > > >> On 20 Dec 2015, at 07:01, Jordan Rose via swift-evolution >>

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-20 Thread Andrey Tarantsov via swift-evolution
> My experience with other languages is that [...] unless you're a Boost > maintainer, people tend to target one version of the language anyway, either > the older one using a workaround portable to the newer version, or the new > version without regards to people stuck behind. That's not how

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-19 Thread David Farler via swift-evolution
> On Dec 19, 2015, at 13:48, Michel Fortin wrote: > >> Le 18 déc. 2015 à 15:22, David Farler via swift-evolution >> a écrit : >> >> #if swift("2.2") >> print("Hello") >> #else >> this code will not parse or emit diagnostics >> #endif > >

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-19 Thread Félix Cloutier via swift-evolution
My understanding is that Swift 3 will stabilize the ABI and the standard library interfaces. Given that, I'm not sure what you'd use it for either. > Le 19 déc. 2015 à 14:26:24, Javier Soto via swift-evolution > a écrit : > > What's the intended most common use case

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-19 Thread David Farler via swift-evolution
That is a fair point of comparison, although this should work for both statements and declarations, in which case the extra attribute style would be redundant. Maybe the implicit >= is good enough. I'd like to keep it as simple as possible. David > On Dec 19, 2015, at 11:26, Javier Soto

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-19 Thread Ludovic LANDRY via swift-evolution
@felix Swift 3 will stabilize ABI (binary level compatibility) but not the standard library interfaces (cf. https://github.com/apple/swift-evolution > Out of Scope > Full source compatibility). Even is they are stabilized in the future, there can still be some API added in future Swift versions.

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-19 Thread Félix Cloutier via swift-evolution
I don't really like how different this makes "#if swift" from "#if ". To me, that would be a violation of the principle of least astonishment. > Le 19 déc. 2015 à 17:08:13, David Farler via swift-evolution > a écrit : > > > >> On Dec 19, 2015, at 13:48, Michel

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-19 Thread David Farler via swift-evolution
I don't know if I would say it violates the principle of least surprise because it wouldn't actually be a surprise in this case, since it's the whole reason you would choose to use `#if swift` – to ignore irrelevant syntax errors. The difference is also smaller than you might think. The #else

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-19 Thread Félix Cloutier via swift-evolution
It's not surprising that what's inside an #if swift block isn't compiled, but since it doesn't, it might be surprising that what is inside an #if DEBUG block is compiled, no? > Le 19 déc. 2015 à 17:58:35, David Farler a écrit : > > I don't know if I would say it violates

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-19 Thread David Farler via swift-evolution
Yes, I see your point in that. It might be worth revisiting that for all of the build configs in the future. David > On Dec 19, 2015, at 15:51, Félix Cloutier wrote: > > It's not surprising that what's inside an #if swift block isn't compiled, but > since it doesn't, it

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-19 Thread Jordan Rose via swift-evolution
> On Dec 19, 2015, at 1:28 , David Farler via swift-evolution > wrote: > > >> On Dec 18, 2015, at 3:34 PM, Douglas Gregor via swift-evolution >> wrote: >> >>> >>> On Dec 18, 2015, at 12:29 PM, Chris Lattner via swift-evolution >>>

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-19 Thread Dirk Schreib via swift-evolution
> On 20 Dec 2015, at 07:01, Jordan Rose via swift-evolution > wrote: > > >> On Dec 19, 2015, at 1:28 , David Farler via swift-evolution >> wrote: >> >> On Dec 18, 2015, at 3:34 PM, Douglas Gregor via swift-evolution

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-18 Thread Radosław Pietruszewski via swift-evolution
Sounds like it could be super useful for libraries! How about we drop the quote marks, though? If we have `os(iOS)` and `#available(iOS 9, *)` (in other context), why not `swift(2.2)`? — Radek > On 18 Dec 2015, at 21:22, David Farler via swift-evolution > wrote: >

[swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-18 Thread David Farler via swift-evolution
Hello everyone, For Swift 2.2, I'd like to add the following build configuration to check for the Swift language version. This is meant to be a short proposal, so let's start with a simple example, compiling with the 2.2 compiler: #if swift("2.2") print("Hello") #else this code will not

Re: [swift-evolution] [Proposal] Swift 2.2: #if swift language version

2015-12-18 Thread David Farler via swift-evolution
A bare 2.2 will work. Right now, 2.2.2 won't lex because of a requirement that member access of a numeric literal be named but, if we decide down the road that we really, really need another version component, it wouldn't be a ton of work to give an exception when parsing an #if config. David