hsutter / cppfront

A personal experimental C++ Syntax 2 -> Syntax 1 compiler
Other
5.23k stars 224 forks source link

[SUGGESTION] Documentation tidbits #1082

Closed MaxSagebaum closed 1 month ago

MaxSagebaum commented 1 month ago

Some small things, that I recognized while browsing the documentation:

Title is wrong: No Trailing commas are present. ( Title is not shown in github view.) https://github.com/hsutter/cppfront/blob/166b59efd818bdc40336ca8ef7b2d94022cedf7f/docs/cpp2/common.md?plain=1#L70

Should be construction: https://github.com/hsutter/cppfront/blob/6dbd1baf511cc4ea73f527ee7e8da23f2dd3a80f/docs/cpp2/types.md?plain=1#L202

Print should be: // "value is [Jim] [(unknown)]" Same for next line. https://github.com/hsutter/cppfront/blob/6dbd1baf511cc4ea73f527ee7e8da23f2dd3a80f/docs/cpp2/types.md?plain=1#L232

The override method is missing its implementation. https://github.com/hsutter/cppfront/blob/6dbd1baf511cc4ea73f527ee7e8da23f2dd3a80f/docs/cpp2/types.md?plain=1#L95

An inspect expr -> Type expression allows pattern matching using is. I think for the reader it is still unclear what is expected on the right side of =. Particularly, I think the definition is not complete. Should it not be: inspect expr -> Type { is condition = statement; ...} My question would be: Can statement also be a body with a return? https://github.com/hsutter/cppfront/blob/d3ad31a2b1701a9f34bf6bc41a49169687ad49e3/docs/cpp2/expressions.md?plain=1#L176

hsutter commented 1 month ago

Thanks, good catches! Will fix.

A couple of questions:

Should be construction:

https://github.com/hsutter/cppfront/blob/6dbd1baf511cc4ea73f527ee7e8da23f2dd3a80f/docs/cpp2/types.md?plain=1#L202

Conversion can be construction and/or assignment, in this case both. But it's a good point that I should clarify this... I'll try adding "conversion from string (construction + assignment)".

Print should be: // "value is [Jim] [(unknown)]" Same for next line.

https://github.com/hsutter/cppfront/blob/6dbd1baf511cc4ea73f527ee7e8da23f2dd3a80f/docs/cpp2/types.md?plain=1#L232

Hmm, that's weird... it prints [] [] on all of the STL implementations I tried, because they clear out the source string on move. But I guess by the spec that's not actually guaranteed... "valid but unspecified state" could leave the source string unchanged, though I would find that surprising behavior. But even if the implementation didn't clear out the source string, then it should be [John] [(unknown)] (not [Jim])? Which STL implementation did you try?

MaxSagebaum commented 1 month ago

Hmm, that's weird... it prints [] [] on all of the STL implementations I tried, because they clear out the source string on move. But I guess by the spec that's not actually guaranteed... "valid but unspecified state" could leave the source string unchanged, though I would find that surprising behavior. But even if the implementation didn't clear out the source string, then it should be [John] [(unknown)] (not [Jim])? Which STL implementation did you try?

Sorry, this was me reading the statement wrong, I did not run it.