-
-
Notifications
You must be signed in to change notification settings - Fork 753
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
Add echo
keyword
#3676
base: main
Are you sure you want to change the base?
Add echo
keyword
#3676
Conversation
Can we get the info from echo without actually pushing it to stdout/stderr for libs like pprint? |
No. |
will string.inspect stay and just io.debug be gone?
|
There will be no changes to |
As far as I'm aware there's no plan to remove Also |
Yes. It would just be nice to utilize what echo does in the long run for things like pprint etc instead of keeping 2 implementations around, imho. Thank you for working on this <3 |
They will always have to be 2 implementations as they do 2 different things. |
3e2f8a0
to
6567af2
Compare
wondering if it would be worth adding something to either the LSP or formatter to replace io.debug calls with echo, to ease the transition post deprecation? not a necessary thing by any means but could be a nice to have DX addition |
The formatter cannot do this as it doesn't analyse your program and cannot know where that |
Probably not worth the effort given |
5733875
to
3c61469
Compare
9f25349
to
df1c688
Compare
This is still missing some integration tests to check the actual echo's output but I'd like to get some feedback on the code so far |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!!! I've left some comments
I think it would be good to include the file and line number in the output of echo
. Perhaps in grey on the line above the printed value? Somewhat similar to how stack traces show
edit: ah! Just noticed the todo list at the top of this PR 💜
.../tests/snapshots/gleam_core__type___tests__echo__echo_in_pipeline_printing_a_function_2.snap
Outdated
Show resolved
Hide resolved
17adb24
to
d8cd1d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a bug! I've pushed a couple of test cases.
The integration test lag is too much, we'll need to do something else there. I'm thinking we invoke the compiler-cli entrypoint directly from within Rust code rather than in a different OS process
b4ff79d
to
b9689a1
Compare
4991759
to
a450fe2
Compare
c37a9df
to
c6f44a9
Compare
Ref: #3216 (comment) |
It does currently |
This PR adds an implementation for the
echo
keyword and closes #2535.It can be used to print any value:
It can also be used in pipes:
And returns the value being printed, so you can slap it everywhere if you need debug printing:
Following from this discussion (#3625) here's a TODO list of things I have to do:
echo
echo
echo
echo
in the middle of a pipelineecho
cannot be used without an expression unless it's as a step of a pipelineecho
io.debug
's lookDict
? The inspect code relied on importingDict
from stdlib but I can't do thatecho
doesn't get publishedio.debug
fromstdlib
(deprecateio.debug
in favour ofecho
stdlib#704)echo
in the language tour (Add Echo to language tour language-tour#132)echo panic
And here's a list of things I've intentionally left out, that could be added in future PRs (for which we could open separate issues):
as "tag"