Arc Forumnew | comments | leaders | submitlogin
1 point by ly47 5139 days ago | link | parent

Hi Thanks all. Now I need a function like read-line. Arc's readline is not like Lisp's read-line. Thanks ly


1 point by waterhouse 5139 days ago | link

Do you refer to the fact that Arc's readline is a bit funky when handling blank lines [and that if you're reading from the terminal, it interprets the input as starting at the end of the s-expression on the current line, so the first character it reads will be the newline], as in:

  arc> (n-of 5 (readline))
  cheese
  
  is
  good
  and
  blah
  ("\ncheese" "\nis" "good" "and" "blah")
  
  ; SBCL
  * (n-of 5 (read-line)) ;n-of isn't standard CL, of course
  cheese
  
  is
  good
  and
  ("cheese" "" "is" "good" "and")
Or are you talking about the various extra little options you can supply to "read-line", like "eof-error-p" or "recursive-p"? [For reference: http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node195.html] Can you describe precisely what is it that you want read-line to do? (It can then be implemented in terms of primitives like readc and peekc. Documentation: http://files.arcfn.com/doc/io.html)

-----

1 point by ly47 5139 days ago | link

Hi Thanks.

I refer to:

SBCL:

  CL-USER> (read-line)
  Hi waterhouse
  "Hi waterhouse"
  NIL
  CL-USER> 
Arc:

  arc> (readline)
  "\r"
  arc>
--------------

ly

-----

3 points by rocketnia 5139 days ago | link

I think newlines you're entering into your console are \r\n, and you're using a version of 'readline that only supports \n newlines (and treats \r as a normal character). Andrew Wilcox has made a fixed version: http://awwx.ws/readline1

Furthermore, you're reading from stdin, the same stream the commands are read from, so what you're reading actually starts right after the ')' character and includes the same newline you used to enter the command. I think someone here might have made a fix for this too (probably Pauan or aw), but you might be able to work around it like this:

  arc> (do (readline) (...now your *actual* stdin-reading code...))
The first (readline) should hopefully get rid of whatever was left over from the input after reading the command.

-----

1 point by ly47 5139 days ago | link

Hi readline1 dose not function as read-line in common lisp. I type (read-line) and and arc is waiting to enter something so I type my string including spaces like: Hi there. output is: "Hi there" NIL Thanks ly

-----

1 point by rocketnia 5139 days ago | link

Right, I expect the version I linked you to doesn't behave exactly like Common Lisp's readline. I just hope it can help. :)

I don't fully understand your example. Did you try something like (do (readline) (readline)), like I was talking about? I'm guessing that since Arc's REPL takes commands and other input from the same stream, it's already different from the REPL you're used to, regardless of how readline works.

-----

1 point by ly47 5139 days ago | link

Hi (do (readline) (readline)) works !!! Thanks ly

-----

1 point by rocketnia 5139 days ago | link

Awesome! ^_^

-----

3 points by rocketnia 5139 days ago | link

You can insert links like this... http://arclanguage.org/formatdoc

...separate paragraphs like this...

...and indent code like this:

  You can insert links like *this*... http://arclanguage.org/formatdoc
  
  ...separate paragraphs like *this*...
  
  ...and indent code like *this*:
  
    You can insert links like *this*... http://arclanguage.org/formatdoc
    
    ...separate paragraphs like *this*...
    
    ...and indent code like *this*:

-----

4 points by akkartik 5139 days ago | link

Yeah I took the liberty of adding the whitespace to make it look like ly seemed to intend.

-----

1 point by zck 5139 days ago | link

Please, please, please give us more information when you have a question. If you want a 'readline exactly like Common Lisp's 'read-line, you'll have to write it yourself. If you want specific features, tell us what they are. It's hard to help when we have to guess what you actually want.

Arc code can be terse; English shouldn't be unnecessarily so.

-----

1 point by ly47 5139 days ago | link

Hi zck Yes, I mean read-line like common lisp. As I'm only learning arc, it will be not easy to me to write it, but I will try as i will be more familiar with Arc. I like arc as it's code is simpler than common-lisp and is more readable. ly

-----