Arc Forumnew | comments | leaders | submitlogin
Reading raw string
3 points by yurez 6316 days ago | 4 comments
I'm trying to get a raw string from console, without luck so far. Read and sread accept objects and readline doesn't do much:

  arc> (readline)
  "\r"
  arc>
Using arc/anarki on windows. Any clues?


2 points by kens1 6316 days ago | link

Readline is reading what is immediately after the (readline):

  arc> (readline)hello world!
  "hello world!\r"
I'm not sure if that's a bug or a feature :-) For the behavior you want, you could try:

  (def myreadline () (let x (readline) (if (is x "\r") (readline) x)))

-----

2 points by yurez 6316 days ago | link

Looks like your version eats empty lines :)

  arc> (repeat 3 (myreadline))
  1
  2
  
  3
  nil
  arc>
Anyway, I think the problem is with readline checking for #\newline char, instead of some magic-os-dependent-line-separator.

-----

3 points by sacado 6316 days ago | link

That looks like a bug dealing with newlines under windows. You could try (do (readine) (readline)) to fix the problem in a first time. I don't know how it could be fixed, but maybe someone else will have an idea...

-----

1 point by almkglor 6316 days ago | link

This is correct, it's a bug. Possibly we can use (which-os) but I'm uncomfortable switching across that.

-----