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

Typing text in Ruby, Javascript and C/C++ not always works #189

Open
eldipa opened this issue Jun 29, 2021 · 0 comments
Open

Typing text in Ruby, Javascript and C/C++ not always works #189

eldipa opened this issue Jun 29, 2021 · 0 comments
Labels
bug out of sync between the code and the docs; something that should be fixed in the near future

Comments

@eldipa
Copy link
Collaborator

eldipa commented Jun 29, 2021

Describe the bug
+type (+input) is an experimental feature and Javascript and C/C++ don't support them because the interpreters don't disable the echoing.

But these languages could still use +type if the example that uses +type it also uses +pass, discarding the output as a workaround for the echoing problem.

However this not always works and worst, Ruby, which does not have an echoing problem, it is also buggy.

Here are the test cases:

Ruby (it should not require +pass):

  >> print "num: "; gets     # byexample: +type  Does Not Work
  num: [42]
  => "42\n"

  >> gets        # byexample: +type  It Works
  [it works!]
  => "it works!\n"

C/C++ (it requires +pass):

  ?: int n;
  ?: std::cout << "num: " << std::flush; std::cin >> n;    // byexample: +type +pass It Works
  num: [42]
  ?: n
  (int) 42

  ?: std::string what;
  ?: getline(std::cin, what);    // byexample: +type +pass Hungs! A Newline is Missing!
  [it works!]
  ?: what
  (std::string &) "it works!"

Javascript (it requires +pass):

  > const readline = require('readline');
  > const rl = readline.createInterface({
  .   input: process.stdin,
  .   terminal: false
  . });

  > var num;
  > rl.question('num: ', (n) => {             // byexample: +input +pass
  .   num = n;
  . });
  num: [42]

  > num
  42

byexample version
byexample 10.1.0

@eldipa eldipa added the bug out of sync between the code and the docs; something that should be fixed in the near future label Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug out of sync between the code and the docs; something that should be fixed in the near future
Projects
None yet
Development

No branches or pull requests

1 participant