Re: [swift-evolution] [Idea] if let value!

2016-05-18 Thread LM via swift-evolution
> On May 18, 2016, at 2:37 PM, Vladimir.S wrote: > > Very interesting. But, as I can see, no community's support for this feature. > I don't mind the lack of interest. chris was very clear that this kind of syntax sugaring is out of scope for 3.0 in general, and that he did not want this on

Re: [swift-evolution] [Idea] if let value!

2016-05-18 Thread Vladimir.S via swift-evolution
I understand *your* idea of let?/let! etc without 'if', but personally I don't support it. I think `if` must be used in this feature. In any case I feel like this idea is not accepted by community, so it seems like there is no sense to discuss its details. On 18.05.2016 16:12, Daniel Höpfl wr

Re: [swift-evolution] [Idea] if let value!

2016-05-18 Thread Daniel Höpfl via swift-evolution
That's the idea of "let?". "let!" would always execute the block (and crash if the optional is nil.) "if let!" is meaningless: "let!" would be true (if the optional is set) or crash (if the optional is nil). On 2016-05-18 14:27, Vladimir.S wrote: The idea to process the 'if' block only if a

Re: [swift-evolution] [Idea] if let value!

2016-05-18 Thread Vladimir.S via swift-evolution
Very interesting. But, as I can see, no community's support for this feature. On 18.05.2016 12:22, LM wrote: I am experimenting with this: If var! anOptional { anOptional // unwrapped, shadowing } if let! anOptional { ... // same } This compiler codebase is truly remarkable, so it shoul

Re: [swift-evolution] [Idea] if let value!

2016-05-18 Thread Vladimir.S via swift-evolution
The idea to process the 'if' block only if anOptional is not null In case of let! anOptional { } IMO it is not clear that this block will be executed *only* if anOptional is not null. if let! anOptional { // here only if anOptional != null } - seems like similar to standard 'if let' construct

Re: [swift-evolution] [Idea] if let value!

2016-05-18 Thread Daniel Höpfl via swift-evolution
Would it be possible to drop the "if"? I don't see why we need it. On 2016-05-18 11:22, LM wrote: I am experimenting with this: If var! anOptional { anOptional // unwrapped, shadowing } if let! anOptional { ... // same } This compiler codebase is truly remarkable, so it should also work

Re: [swift-evolution] [Idea] if let value!

2016-05-18 Thread LM via swift-evolution
I am experimenting with this: If var! anOptional { anOptional // unwrapped, shadowing } if let! anOptional { ... // same } This compiler codebase is truly remarkable, so it should also works with If var! opt1 where opt1 < 27 { } or if var! opt1, opt2 { // both unwrapped } LM/ > O

Re: [swift-evolution] [Idea] if let value!

2016-05-18 Thread Daniel Höpfl via swift-evolution
Just an idea: Why don’t we think about it similar to try? var anOptional : String? let? anOptional { /* use it, but cannot change it */ } let! anOptional { /* use it, without checking, cannot change it */ } var? anOptional { /* use it, can also change it, */ } var! anOptional { /* use it, withou

Re: [swift-evolution] [Idea] if let value!

2016-05-18 Thread Krishna Kumar via swift-evolution
Adding a keyword `unwrap` might reduce the code repetition but I think it will be confusing to use a keyword to unwrap something while we already have a way to do that. I think two ways to do one thing impacts clarity. I understand that `unwrap` is a replacement for Optional Binding and optiona

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread L Mihalkovic via swift-evolution
interestingly enough, it looks like a truly simple task... the grammar has 2 types of BindingKind at that location BK_Let and BK_Var, which means that a single shorthand notation will assume one of the other, which means that if it does assume one, then it better be explicit about it, or alterna

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Austin Zheng via swift-evolution
A case can be made, of course. My personal opinion is that I don't want to see it in the language at any point. Others are free to agree or disagree. Austin > On May 17, 2016, at 9:21 AM, Matthew Johnson wrote: > > >> On May 17, 2016, at 11:18 AM, Austin Zheng wrote: >> >>> >>> If people r

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Vladimir.S via swift-evolution
On 17.05.2016 19:08, Matthew Johnson wrote: it might be worth looking at other aspects of how your code is structured. All is good, if it is in *my* code ;-) But I often see this pattern in *others* code and I don't want to see it in others code :-) ___

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Matthew Johnson via swift-evolution
> On May 17, 2016, at 11:18 AM, Austin Zheng wrote: > >> >> If people really want to pursue further sugar here I think it would be >> worthwhile to explore a direction that hasn’t already been debated >> extensively. That is why I suggested thinking about `if unwrap`. That >> said, I reall

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Vladimir.S via swift-evolution
On 17.05.2016 18:58, Matthew Johnson wrote: That said, I really don’t think current state is too bad. It’s definitely not worth expending community energy on this when we clearly have more important things to focus on (like completing generics and ABI). Well.. Although I agree that this is not

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Austin Zheng via swift-evolution
> > If people really want to pursue further sugar here I think it would be > worthwhile to explore a direction that hasn’t already been debated > extensively. That is why I suggested thinking about `if unwrap`. That said, > I really don’t think current state is too bad. It’s definitely not w

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Matthew Johnson via swift-evolution
> On May 17, 2016, at 11:06 AM, Vladimir.S wrote: > > On 17.05.2016 18:48, Matthew Johnson via swift-evolution wrote: >> Being syntactic sugar for something that is already not too bad > > Well.. Personally I feel like construction `if let someMyValue = someMyValue` > is bad exactly because of

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread LM via swift-evolution
Regards LM (From mobile) > On May 17, 2016, at 5:48 PM, Matthew Johnson via swift-evolution > wrote: > > >> On May 17, 2016, at 10:41 AM, Brandon Knope wrote: >> >> I always thought a new keyword made more sense here: >> >> if let rebind someValue { >> //use shadowed unwrapped value

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Vladimir.S via swift-evolution
On 17.05.2016 18:48, Matthew Johnson via swift-evolution wrote: Being syntactic sugar for something that is already not too bad Well.. Personally I feel like construction `if let someMyValue = someMyValue` is bad exactly because of this the same repeated name. Anywhere I see repeated code, I

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Matthew Johnson via swift-evolution
> On May 17, 2016, at 10:50 AM, Vladimir.S wrote: > > Could you clarify how to use `if case` to achieve the same target as proposed > `if let value!` ? > (btw, probably `if let value? {..}` will be better) You don’t get the same implicit match that this idea proposes, but you do get the full

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Brandon Knope via swift-evolution
It’s not just about being concise, but reducing repeated code: It would be syntactic sugar for this: if case .Some(let optional) = optional { } But yes, unwrap makes much more sense. At the end of the day, I am not too bothered by if let syntax, but if we could clear up some of the repetit

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Vladimir.S via swift-evolution
Could you clarify how to use `if case` to achieve the same target as proposed `if let value!` ? (btw, probably `if let value? {..}` will be better) On 17.05.2016 18:18, Matthew Johnson wrote: On May 17, 2016, at 10:13 AM, Tony Allevato via swift-evolution mailto:swift-evolution@swift.org>> wr

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Matthew Johnson via swift-evolution
> On May 17, 2016, at 10:41 AM, Brandon Knope wrote: > > I always thought a new keyword made more sense here: > > if let rebind someValue { > //use shadowed unwrapped value in here > } > > if let bind someValue { > //use shadowed unwrapped value in here > } > > > if let unwrappe

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Brandon Knope via swift-evolution
I always thought a new keyword made more sense here: if let rebind someValue { //use shadowed unwrapped value in here } if let bind someValue { //use shadowed unwrapped value in here } if let unwrapped someValue { } Something along those lines? Brandon > On May 17, 2016, a

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread LM via swift-evolution
Now *that* reminds me of the _ voodoo in perl... and i was under the impression that magic symbols are not highly regarded in swift (which I really appreciate!!) Regards LM (From mobile) > On May 17, 2016, at 5:31 PM, Patrick Smith via swift-evolution > wrote: > > Here’s a idea, what if you

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread LM via swift-evolution
FWIW, agreed that more complex guard statements with shorter methods avoid the issue altogether (reminds me of using unless for similar purpose in perl). Regards LM (From mobile) > On May 17, 2016, at 5:15 PM, Sean Heber via swift-evolution > wrote: > > Yep - same here. I think I was one of t

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Patrick Smith via swift-evolution
Here’s a idea, what if you could use a symbol to denote that you want the same name used? Here’s an interesting sign from music: https://en.wikipedia.org/wiki/Repeat_sign Then you can write (one) of these: if let |: = mySomeValue { // Use unwrapped } if let mySomeValue = :| { // Use unwrap

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Matthew Johnson via swift-evolution
> On May 17, 2016, at 10:13 AM, Tony Allevato via swift-evolution > wrote: > > While I've sometimes (early on) wished for a shorter-hand syntax for that > construct, I've never been able to think of something that I thought was > better. I've gotten to the point where I don't particularly min

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Sean Heber via swift-evolution
Yep - same here. I think I was one of the first to propose we find some solution to this on the list back when it first started, and oddly enough, with more Swift experience comes less and less feeling of this even being a problem. I think as you start thinking more “in Swift” you start structur

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Tony Allevato via swift-evolution
While I've sometimes (early on) wished for a shorter-hand syntax for that construct, I've never been able to think of something that I thought was better. I've gotten to the point where I don't particularly mind it anymore. Regarding the exclamation point specifically, seeing one of those in an ex

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Vladimir.S via swift-evolution
On 17.05.2016 16:51, Johan Jensen wrote: > This was one of the first and most commonly suggested ideas, when the Swift > Evolution mailing list first started. > Chris Lattner sums it up > > in one of those threa

Re: [swift-evolution] [Idea] if let value!

2016-05-17 Thread Johan Jensen via swift-evolution
This was one of the first and most commonly suggested ideas, when the Swift Evolution mailing list first started. Chris Lattner sums it up in one of those threads: > This is commonly requested - the problem is tha

[swift-evolution] [Idea] if let value!

2016-05-17 Thread Vladimir.S via swift-evolution
It is common to shadow optional value name with unwrapped value with same name: if let someGoodValue = someGoodValue {...} What if we'll have a syntax to not repeat the variable name to achieve the same target: if let someGoodValue! {...} What do you think? __