> On Apr 4, 2016, at 7:25 AM, Jim Malak via swift-users <[email protected]> 
> wrote:
> 
> My background going into Swift was everything but JavaScript. One thing I 
> often wondered about (usually every time I forgot to type it) is what purpose 
> does requiring the keyword “func” serve when defining or decaling a function 
> in Swift. I am not a compiler expert but intuitively it would seem that the 
> function signature could be readily recognized by the complier and people 
> alike with the presences of the ()’s at the end.
>  

Swift’s grammar follows a very regular structure, where declarations are 
introduced with a keyword.  This structure has a number of advantages when 
parsing.  For example, it allows “modifiers” like “mutating” and “public” to be 
context sensitive identifiers instead of themselves being keywords.  It also 
helps with more subtle things like error recovery in the face of invalid code 
that produces parsing errors.

-Chris

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

Reply via email to