Open straight-shoota opened 2 years ago
I think pry doesn't work well in many cases. For example, block arguments are not visible. In general, I feel that pry has still a long way to go
After https://github.com/crystal-lang/crystal/pull/11578 is merged, the first thing I would do is to write at least one spec for debugger
and pry
. There's a lot to fix and improve there, and without tests it's going to be tough.
My idea was to have tests specify three things:
debugger
call in itFor example:
assert_interpreter_debugger(
code: "a = 1; debugger; a",
input: "a",
expected_output: "1",
)
That is, after debugger
is reached, the user types "a" on the console, and they expect to get "1" as the output.
This will require adapting the interpreter so that the input and output are not tied to STDIN and STDERR, which might also eventually make it possible to hook the interpreter into code editors.
These tests will also be independent of the underlying implementation, so they will be extremely useful and resilient to changes.
With those tests in place, I could start working on some of them to fix existing bugs, like https://github.com/crystal-lang/crystal/issues/11555#issuecomment-989295051
@asterite just to clarify, each of the lines stating BUG: missing handling... is a TODO waiting to be completed, right? (Just stumble across one of this).
That's it! Maybe I should have put a TODO there π
I assume the issue that happens when attempting to require "openssl"
or anything that relies on openssl is included in one of these subtasks? The issue seems to be different based on whether you require openssl in the repl or in a file the interpreter is running, but both break.
If other people aren't having this problem for some reason I'll gladly make a new issue.
That is, after
debugger
is reached, the user types "a" on the console, and they expect to get "1" as the output.
https://github.com/Ivo-Balbaert/programming_crystal/blob/master/exercises/crystal_new/fibers.cr
Something really slow about channels. crystal i <filename>
this thing grinds my computer to a halt i barely Ctrl-c'd at 1507 out of 10000 iterations. crystal r <filename>
completes smoothly in a blink of an eye. Linux x86-64
# START:p1
chan = Channel(String).new
i = 0
num = 10000
num.times do
spawn do
chan.send "fiber #{i}: I like crystals!"
end
i += 1
puts chan.receive
end
# =>
# fiber 1: I like crystals!
# fiber 2: I like crystals!
# fiber 3: I like crystals!
# fiber 4: I like crystals!
# ...
# fiber 10000: I like crystals!
# END:p1
Can confirm similar results on MacOS (Intel) with Crystal 1.5.0
Yes, the interpreter is slower than compiled mode. And I have no immediate plans to improve its speed.
What's missing for the interpreter:
Crystal::Loader
integration (#11579)asm
support (interpreter bytecode)src/compiler/crystal/repl
Feel free to post comments for additional items here.
No discussion on individual items. Thank you πββοΈ
That should be moved to dedicated issues. If none exists, please open one or start an informal discussion at https://forum.crystal-lang.org/