Arc Forumnew | comments | leaders | submit | ly47's commentslogin
1 point by ly47 5139 days ago | link | parent | on: Remove-if-not

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

-----

1 point by ly47 5141 days ago | link | parent | on: Remove-if-not

Hi Thanks all, problem solved by waterhouse. Now I have some other problems: 1. progn in Arc ? 2.find with a :key in Arc ? Thanks ly

-----

2 points by zck 5141 days ago | link

>1. progn in Arc ?

'do, as in the following[1]:

  (if (< (rand) 0.5)
      (do (prn "No, Mr. Bond, I expect you to die...")
          (-- mi6 007)))
Some of your questions may be answered if you read through the tutorial: http://ycombinator.com/arc/tut.txt There's stuff you won't pick up on the first time that you'll want to know later.

>2.find with a :key in Arc

An example in Common Lisp, just to make sure we're talking about the same thing:

  [1]> (find 'vader
             '((indiana-jones whip snakes)
               (vader lightsabre light-side)
               (dijkstra EWDs goto)))
  NIL
  
  [2]> (find 'vader
             '((indiana-jones whip snakes)
               (vader lightsabre light-side)
               (dijkstra EWDs goto))
             :key #'car)
  (VADER LIGHTSABRE LIGHT-SIDE)
The behavior in #2, correct? You'll have to make a function to perform the key action on the element, as in the following:

  arc> (find [is (car _) 'vader]
             '((indiana-jones whip snakes)
               (vader lightsabre light-side)
               (dijkstra EWDs goto)))
  (vader lightsabre light-side)
As a side note, you asked [2] about getting SLIME set up on Windows. I wrote up a guide on how to set it up on Linux; you can probably plunder it for information about how to set it up on Windows. I also had a few questions about your setup; it's not at all like mine.

[1]Yes, this is just 'when. Shush, it's an example.

[2]http://arclanguage.com/item?id=14958

-----

1 point by ly47 5141 days ago | link

Hi zck Thanks a lot . Problems of find with :key and progn in Arc solved. About emacs and Arc still don't work. I use emacs for common-lisp with lisp-cabinet. For an editor I use scite which i configured to work with Arc(I had to make write some scripts with AutoIt) Thanks again ly

-----

2 points by zck 5141 days ago | link

Sorry, I forgot to link my SLIME thread: http://arclanguage.com/item?id=14998

Could you answer my questions in your other thread? http://arclanguage.com/item?id=15002 It's really hard to try to help you without more details than "emacs and Arc still don't work".

-----

1 point by ly47 5141 days ago | link | parent | on: Remove-if-not

Hi Thanks. 'keep is good but it does not work with my code as I use a loacl function inside before using 'keep. So what to use instead of labels or flet in ARC ? Thanks again ly

-----

4 points by waterhouse 5141 days ago | link

Like this?

  ; Common Lisp:
  (flet ((f (x y)
           (blah blah x y)))
    (remove-if-not f xs))

  ; Arc:
  (let f (fn (x y)
           (blah blah x y))
    (keep f xs))

-----

1 point by ly47 5141 days ago | link

Hi Yes it works !!! Thanks ly

-----

1 point by ly47 5148 days ago | link | parent | on: Emacs+arc on windows

Hi Thanks for your reply. Yes I want get slime working with Arc... I run clisp/sbcl/ccl in Emacs as follow: 1-Using lispBox or lisp-cabinet.(with slime and quicklisp) 2.Using emacs with my own .emacs configuration.(with slime) ly

-----

1 point by zck 5147 days ago | link

I do keep meaning to get SLIME set up, but haven't actually tried yet. If you list what problems you run into, people will be able to help you more easily.

-----

1 point by shader 5144 days ago | link

You know, every once in a while I consider setting up slime, or at least looking at it, but I've never used slime before and I don't really know what it offers.

What are your favorite features of slime, and why would I want to use it over just emacs + arc.el + repl-in-shell?

-----

1 point by ly47 5147 days ago | link

Hi As there is no slime support for Arc I tried to load arc.el to emacs but, it failed with this message: arc.el:411:30:Error: Required feature `cl-macs' was not provided.

-----

1 point by shader 5144 days ago | link

What version of emacs are you using? Maybe you'll need to upgrade or install cl-macs.el.

-----

1 point by ly47 5141 days ago | link

Hi I'm using emacs Emacs 23.3.1 and cl-macs.el is installed. I type arc-mode and I get Arc in the menu, but when i choose Run inferior-arc error message:error: Required feature `cl-macs' was not provide. Thanks

-----

2 points by zck 5141 days ago | link

What is arc.el? There's no arc-mode for Emacs that I know of. What are you expecting to happen when you type M-x arc ? Where did you get arc.el?

I wrote up instructions on how to get SLIME working with Arc, but I don't have a Windows box to test on. Can you translate the directions to Windows, and then see if it works for you? http://arclanguage.org/item?id=14998 Notably, you don't start SLIME by typing M-x arc-mode; you start it by typing M-x slime .

-----

1 point by ly47 5141 days ago | link

Hi https://github.com/nex3/arc/tree/master/extras ly

-----

1 point by zck 5140 days ago | link

Ah. This isn't SLIME. As akkartik said, it's likely that no one here uses it. If you want to try SLIME, follow my instructions here: http://arclanguage.org/item?id=14998

-----

1 point by akkartik 5141 days ago | link

Ah, I'd forgotten about that. It hasn't been touched in over a year (http://github.com/nex3/arc/commits/master/extras/arc.el); I'm not sure if anyone here has experience with it.

-----

2 points by shader 5135 days ago | link

I definitely use arc.el on a regular basis, though I won't claim to be familiar with the finer points of its capabilities. As far as I'm concerned, it offers reasonable highlighting and indentation for arc code; I haven't tried to get it to do much else. For most of my lisp editing needs, I rely on paredit.

-----