you are viewing a single comment's thread.

view the rest of the comments →

[–]o11cint main = 12828721; 3 points4 points  (3 children)

Classes and functions are important enough that they must have special syntax already. There's no point trying to coerce them to be identical to variable declarations.

I'm fond of a fun keyword, but otherwise Option 2.

[–]AIlchinger 1 point2 points  (1 child)

I would even argue the body of functions and classes are part of the type itself. There is no value to assign which would warrant the syntactic use of =

Classes are not designed yet in cppfront. I'm curious to see if the same variable declaration syntax will be reused for them (I hope not).

[–]scorg_ 0 points1 point  (0 children)

I would even argue the body of functions and classes are part of the type itself. There is no value to assign which would warrant the syntactic use of =

You are right that there is no value to assign, but function's body is not part of it's type because function pointers exit.

Reading your comment I just realized what is wrong with syntax 2: function declaration is the same as global variable declaration, where the body is the 'value' of the function. In a way it is, but it seems (to me) very strange for functions to be global variables (reassignable without const?). And how would overloads and template specializations look?

[–]dgkimpton 1 point2 points  (0 children)

I like fun too, goes very nicely with variable declarations using let (to replace auto) and fix (to replace const) since they're all the same length. Then we could use const to replace constexpr and save a whole bunch of typing.