Hacker News new | ask | show | jobs
by watergatorman 2720 days ago
By 2 styles of pointers used in functions, see below taken from your examples.

By reading both left-to-right and right-to-left I mean: "star" pointer in front of the identifier read right-to-left with return function type on the left and ampersand pointer read left-to-right with return function type on the right of "->"

Here are 2 of your function examples you gave:

This example has both an outermost "void" function return type on the left and another to the right of "->" "void (* f)(g &(int) -> void)" Instead use the following to always read left-to-right and get rid of the "star" pointer: "f &(g &(int) -> void) -> void"

Your next example has 2 "void" function return types on the left, and one "void" to the right of "->" "void (* f)(g &(void (* h)(x &int)) -> void)" Instead use the following to always read left-to-right: "f &(g &(h &(x &int) -> void) -> void) -> void"

1 comments

I did say "original C declaration syntax forms needs to be deprecated and only the newly invented syntax forms should be used". So the new invented syntax alone is complete (you can express anything with &, (args)->ret and [count]type).
Ok, I got it now. Thanks. My faulty understanding.

I believe you have a clean, readable syntax for C declarations.

The Go Programming Language's declaration syntax is very similiar, except that "star" is retained and acts just as your "&"

I don't have a complete list, but have been looking at classifying programming languages into one of 2 categories:

Category 1 declaration syntax: Type identifier ;

or

Category 2 declaration syntax: identifier Type ; with perhaps a colon or other punctuation between the identifier and Type.