hsutter / cppfront

A personal experimental C++ Syntax 2 -> Syntax 1 compiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[SUGGESTION] Documentation tidbits

MaxSagebaum opened this issue · comments

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.)

``` cpp title="Lists, using optional trailing commas just because we can" hl_lines="1 4 6 7"

Should be construction:

// conversion from string

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

x.print(); // "value is [] []" - moved from

The override method is missing its implementation.

print: (override this, msg: std::string);

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?

An `inspect expr -> Type` expression allows pattern matching using `is`.

Thanks, good catches! Will fix.

A couple of questions:

Should be construction:

// conversion from string

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.

x.print(); // "value is [] []" - moved from

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?

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.