> Am 11.06.2016 um 21:59 schrieb Xiaodi Wu <[email protected]>:
> 
> 
> 
>> On Sat, Jun 11, 2016 at 2:53 PM, Thorsten Seitz <[email protected]> wrote:
>> 
>> 
>>> Am 10.06.2016 um 18:28 schrieb Xiaodi Wu via swift-evolution 
>>> <[email protected]>:
>>> 
>>>> On Fri, Jun 10, 2016 at 6:10 AM, Karl <[email protected]> wrote:
>>>> -1
>>>> 
>>>>> * Swift is explicitly a C-family language. In most or all other C-family 
>>>>> languages, for loop statements allow specification of conditions for 
>>>>> exiting the loop but not for filtering. Therefore, Swift's use of `where` 
>>>>> is unprecedented and needs to be learned anew by every user of Swift.
>>>> 
>>>> When was this decided? I distinctly remember some bloke under Craig 
>>>> Federighi’s hair saying that it was time to “move beyond” C and 
>>>> essentially ditch legacy conventions which no longer make sense.
>>> 
>>> I think you misunderstood my argument here. I don't mean that we should 
>>> yoke ourselves to C conventions, and we should absolutely ditch C 
>>> convention when it doesn't make sense. The big-picture argument here is 
>>> that `where` doesn't pass the bar of correcting a C convention that no 
>>> longer makes sense.
>>> 
>>> FWIW, on the topic of syntax choices, here is what Chris Lattner had to say 
>>> on this list:
>>> 
>>>> Kevin got it exactly right, but I’d expand that last bit a bit to:
>>>> “… picking the one that is most familiar to programmers in the extended C 
>>>> family is a good idea.["]
>>>> The extended C family of language (which includes C, C++, ObjC, but also 
>>>> C#, Java, Javascript, and more) is
>>>> an extremely popular and widely used set of languages that have a lot of 
>>>> surface-level similarity. I
>>>> don’t claim to know the design rationale of all of these languages, but I 
>>>> surmise that this is not an
>>>> accident: programmers move around and work in different languages, and 
>>>> this allows a non-expert in the
>>>> language to understand what is going on. While there are things about C 
>>>> that are really unfortunate IMO
>>>> (e.g. the declarator/declaration specifier part of the grammar) there is a 
>>>> lot of goodness in the basic
>>>> operator set, focus on dot syntax, and more.
>>>> I do agree that there are some benefits to ditching braces and relying on 
>>>> indentation instead, but there are
>>>> also downsides. Deviating from the C family in this respect would have to 
>>>> provide *overwhelmingly* large 
>>>> advantages for us to take such a plunge, and they simply don’t exist.
>>>  
>>>> As I understand it, Swift is a new language with new conventions. It is 
>>>> desirable to align as many of those as possible with existing conventions 
>>>> so as to be easily learned, but if you limit Swift to other languages 
>>>> conventions you deny it any identity. Did Python ask anybody’s opinion 
>>>> before dropping curly-braces? Did people learn whatever Perl is supposed 
>>>> to be? Look at C’s hieroglyphic for loops! 
>>> 
>>> I don't think we disagree here.
>>>  
>>>> 
>>>> Realistically, “for … in … while” is not going to cause incredible 
>>>> confusion. Removing it would cause a lot of frustration. You can’t on the 
>>>> one hand say our users are comfortable with the axioms of C’s hieroglyphic 
>>>> loops, and on the other hand say “for x in y while" is confusing.
>>>> 
>>>>> Again, as I said, once you've mastered something, by definition you find 
>>>>> it not confusing. Why should we doom x% of new users to writing a loop 
>>>>> incorrectly at least once when we don't have to?
>>>> 
>>>> 
>>>> Ah, but if you’re not “doomed” to failing once, how will you ever master 
>>>> anything? Nobody knew how to write a C for-loop until someone showed them 
>>>> (and even then…). Nobody is going to just open a REPL and start writing 
>>>> code, with zero prior understanding of what Swift syntax looks like.
>>> 
>>> The thought here is along the lines of what Chris said, quoted above, and 
>>> repeated here: "The extended C family of language [...] is an extremely 
>>> popular and widely used set[;] programmers move around and work in 
>>> different languages, and [aligning to expectations arising from other C 
>>> family languages] allows a non-expert in the language to understand what is 
>>> going on." By contrast, the `where` clause violates that expectation and I 
>>> do not see "overwhelmingly large advantages" for doing so.
>> 
>> What about C#'s `where` then? As C# is a member of the C family languages 
>> `where` is not violating expectations!
> 
> C# does not have a where keyword for its foreach loop, afaik.

`where` is an essential part of C#'s LINQ feature, see 
https://msdn.microsoft.com/de-de/library/bb397906.aspx for example.

-Thorsten 
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to