Skip to content

Code readthrough, comments #7

@bisqwit

Description

@bisqwit

I had a brief read through your cons_expr.hpp. Fascinating code. Assorted comments below:

Category: Great idea!

[[nodiscard]] attribute on ++(int), --(int), begin() etc.

Category: Could be better?

pow(): Could use the much more efficient binary exponentiation algorithm: for(result = 1; power != 0; power >>= 1, base *= base) if(power & 1) result *= base; (similarly /= for negative exponents)

Category: Why the discrepancy?

pow(): Parameter is long long, but is iterated using int.
parse_float(): Accepts "-.4" but not ".4".
parse_float(): Accepts "13.4e2" and "13.4e-2". Accepts "13e2" but not "13e-2".

Category: Errors?

parse_float(): Accepts "-e2".
next_token(): Interprets both "a\"b" and "a\\"b" as valid string constants.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions