echo
keyword
#3625
Replies: 1 comment 2 replies
-
Thank you for this Jak! Very good write-up.
I feel this syntax implies that the message syntax for
I think it would make sense to be consistent with
Sounds reasonable.
We could also include the location of the expression perhaps? We can iterate on this output too as it's not a stable interface, it's debug output.
The code would still be needed in stdlib for Deprecating
That's a really interesting idea! We could add labels as we could have the information statically! I think this could be a future addition as the output is not a stable API. |
Beta Was this translation helpful? Give feedback.
-
Hello! Since
echo
was reserved as a keyword I'd like to start talking about how it could work and be implemented to (hopefully) get it done in time for v1.6 :)echo
would be used followed by an expression to print. It could be any kind of expression, not just aString
value.echo
is not a function so we want it to not look like one (the same goes forpanic
andtodo
). So ifecho
is not followed by a value to print it should result in an error:echo
will return the value it's being fed.echo
to make it easier to find a specific output. In that case one might add anas "string tag"
to anecho
:echo
to be published to Hex, so if the build tool finds any it will have to refuse to publish a package explaining why. We already do this fortodo
s so it could probably be pretty straightforward copying that.Open questions
io.debug
afterecho
is implemented? I think that afterecho
is implemented we should deprecate and removeio.debug
from stdlib to avoid having two ways to do the same thing.io.debug
would be more awkward and the compiler doesn't give you the same guarantees that it won't end up in a published package by accident.echo
look like? Do we want to copy whatio.debug
is doing, try do to something different (like Rust's debug formattingprintln!(":#?")
)echo
's pretty printed output be considered breaking changes? And so do we need to nail it immediately or do we have room to improve it in the future without warranting a compiler's major version bump?stdlib
is a project's dependency and replaceecho
with a call toio.debug
under the hood. What would happen in the unlikely case where a project doesn't depend on stdlib? In addition I believe the right way to move forward would be to deprecate and removeio.debug
afterecho
is implemented in the language so I'd prefer to never depend on it for this feature to workecho
is implemented in the compiler itself we could rely on the type information to pick the better pretty printing strategy for the value at hand. For example if something is inferred to be a string vs something being inferred as a bit array. Right now, sinceio.debug
relies solely on the runtime shape of the data we sometimes have to manually pick a different implementation (seeio.debug
vsbit_array.debug
). There's cases where this would still be impossible:Whatever we end up deciding we should document somewhere these corner cases that would make interpreting
echo
's output a bit confusing for newcomers. For example how an Erlang tuple like{wibble, 1, 2}
would be printed asWibble(1, 2)
even if the program doesn't define a type with aWibble
variant at allI would love to hear other's feedback especially on what
echo
's output could look like!Beta Was this translation helpful? Give feedback.
All reactions