Thanks Jens, My main languages are C#, c, obj-c and now Swift. You can appreciate my point of view. I’ll just assume that adding “func” contributes towards the common good.
Thanks for responding. - Jim From: Jens Alfke <j...@mooseyard.com> Date: Monday, April 4, 2016 at 2:32 PM To: Jim Malak <jim.ma...@beryle-lee.com> Cc: "swift-users@swift.org" <swift-users@swift.org> Subject: Re: [swift-users] Question out of curiosity: why "func" On Apr 4, 2016, at 7:25 AM, Jim Malak via swift-users <swift-users@swift.org<mailto:swift-users@swift.org>> wrote: My background going into Swift was everything but JavaScript. Have you used Ruby or Python, both of which use a “def” keyword before a definition? And come to think of it, I think most non-C-derived languages use some sort of keyword before a function definition. Just to name two language families, LISP uses “def” and Pascal uses “function” or “procedure”. So C (and C++ and Java and C#…) may be the oddballs here in not using a keyword, along with some functional languages. 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. I can’t speak for the details of Swift’s language grammar. I do know that adding not-strictly-necessary redundancies like this to a grammar is very useful for helping the parser understand the intended meaning of a syntax error, and thereby producing a meaningful error message. (This is one of the reasons C++ error messages can be notoriously unhelpful: the syntax is so complex with so many possible ambiguities, that the error message may refer to a language construct that you weren’t even intending to use.) —Jens
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users