Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] print arrays or dicts, that contain unprintable types and printable types #8207

Open
Volker-Weissmann opened this issue Jan 15, 2021 · 3 comments · May be fixed by #11589
Open

Comments

@Volker-Weissmann
Copy link
Contributor

Volker-Weissmann commented Jan 15, 2021

Hello,

it would make debugging a lot easier if the message(text) function would work recursively on arrays and dictionaries, similar like rust's #[derive(debug)].

@dcbaker
Copy link
Member

dcbaker commented Jan 15, 2021

What version are you using? I think that message() will work recursively with arrays in recent versions of meson. I doubt it handles dicts correctly still.

@Volker-Weissmann
Copy link
Contributor Author

I'm using ea2f34e , but I just realized my question is badly worded:
Lists and Dict work fine if they only contain printable types. But if you have just one variable that is not printable, like that:

cppc = meson.get_compiler('cpp')
m_dep = cppc.find_library('m')
ar = [1,2,3, m_dep]

you can no longer print and see anything of ar. It would be nice if message(ar) would print something like

[1,2,3, --unprintable--]

or something like

[1,2,3, dependency-type of library 'm']

@Volker-Weissmann Volker-Weissmann changed the title [Feature Request] message array or dict [Feature Request] print arrays or dicts, that contain unprintable types and printable types Jan 15, 2021
@xclaesse
Copy link
Member

Many objects already implement __repr__ but we probably would have to come with more user friendly representations. I think it would make sense for InterpreterObject to have a default to_string() method that would return something like --internal-- and override that method everywhere we can make more useful representation.

This is something I needed a few times too, I usually add prints in meson code itself when I need to debug something, clearly not user friendly way.

Volker-Weissmann added a commit to Volker-Weissmann/meson that referenced this issue Mar 25, 2023
…ntly) cannot be printed.

Make `file`, `compiler`,  and `module` objects printable.
In future commits, we should make even more types printable.
Fixes mesonbuild#8207
@Volker-Weissmann Volker-Weissmann linked a pull request Mar 25, 2023 that will close this issue
Volker-Weissmann added a commit to Volker-Weissmann/meson that referenced this issue Mar 25, 2023
…ly) cannot be printed.

Make `file`, `compiler`, `module` and `disabler` objects printable.
In future commits, we should make even more types printable.
Fixes mesonbuild#8207
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants