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

Metaissue: Improve the interpreter #11555

Open
12 of 22 tasks
straight-shoota opened this issue Dec 8, 2021 · 9 comments
Open
12 of 22 tasks

Metaissue: Improve the interpreter #11555

straight-shoota opened this issue Dec 8, 2021 · 9 comments

Comments

@straight-shoota
Copy link
Member

straight-shoota commented Dec 8, 2021

What's missing for the interpreter:

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/

@asterite
Copy link
Member

asterite commented Dec 8, 2021

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

@asterite
Copy link
Member

After #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:

  • a source, which has a debugger call in it
  • given input
  • expected output

For 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 #11555 (comment)

@beta-ziliani
Copy link
Member

@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).

@asterite
Copy link
Member

That's it! Maybe I should have put a TODO there 😅

@watzon
Copy link
Contributor

watzon commented Jan 10, 2022

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.

@HertzDevil
Copy link
Contributor

HertzDevil commented Jun 18, 2022

That is, after debugger is reached, the user types "a" on the console, and they expect to get "1" as the output.

#12119 does this for LLDB. We could probably use FileCheck here or even share the same test source files for multiple CLI debuggers (another one I have in my mind is GDB).

@mwgkgk
Copy link

mwgkgk commented Aug 9, 2022

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

@mdwagner
Copy link
Contributor

mdwagner commented Aug 9, 2022

Can confirm similar results on MacOS (Intel) with Crystal 1.5.0

@asterite
Copy link
Member

asterite commented Aug 9, 2022

Yes, the interpreter is slower than compiled mode. And I have no immediate plans to improve its speed.

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

No branches or pull requests

7 participants