FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[SUGGESTION] Better "printf debugging" · Issue #1409 · hsutter/cppfront · GitHub

[SUGGESTION] Better "printf debugging" #1409

Description

Essentially, implement the "self-documenting f-strings" from Python (link to feature). Note that today most of Python-style formatting is already supported OOTB (Link to cppfront documentation), since C++'s standard format specification is based on Python's specification (cppreference), this is just a small but nice productivity enhancement to have.

Examples:

>>> my_var = 42
>>> f"Prefix|{my_var}|Postfix"
'Prefix|42|Postfix'
>>> f"Prefix|{my_var=}|Postfix"
'Prefix|my_var=42|Postfix'
>>> f"Prefix|{my_var =}|Postfix"
'Prefix|my_var =42|Postfix'
>>> f"Prefix|{my_var = }|Postfix"
'Prefix|my_var = 42|Postfix'
>>> my_f = lambda x: x+2
>>> f"Prefix|{my_f(2)}|Postfix"
'Prefix|4|Postfix'
>>> f"Prefix|{my_f(2)=}|Postfix"
'Prefix|my_f(2)=4|Postfix'
>>> f"Prefix|{my_f(2) =}|Postfix"
'Prefix|my_f(2) =4|Postfix'
>>> f"Prefix|{my_f(2) = }|Postfix"
'Prefix|my_f(2) = 4|Postfix'

You can then imagine how cppfront's would look like:

test: std::string_view = "My String";
main: () = std::cout << "Prefix|(test = )$|Postfix";

// Outputs: Prefix|test = My String|Postfix

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL