Live data from Hacker News

Scripting in Common Lisp

ebzzry.io

1–10 of 41 posts

Re: Scripting in Common Lisp

#2
This is a great guide, and solving quick real problems is how people get started programming in general.

I think seeing scsh for the first time made me realize just how good & bad shells are.

Re: Scripting in Common Lisp

#5

Where is your piping example?

I do not use cl-launch, but for some tasks at job I wanted to pipe programs, and just wanted to try implementing something myself. The with-pipeline macro creates temporary fifos to connect programs and threads (random example):

    (let ((counter 0))
      (with-pipeline ()
        (program "ls" "-1la")
        (lambda-line (line)
          (format t "~x~%" (incf counter (length line))))
        (program "sed" "-n" "s/A/_/g ; /__/ p"))
      counter)
         
Outputs and return:

    2__8
    15399
Macroexpansion:

   (catch :pipeline
     (block nil
       (let* ((#:input%2195 (pipeline::ensure-stream nil :input nil))
              (#:output%2196 (pipeline::ensure-stream t :output nil))
              (#:error%2197
               (pipeline::ensure-stream :output :error #:output%2196)))
         (let ((#:g2199 (program "ls" "-1la"))
               (#:g2200
                (lambda-line (line)
                  (format t "~x~%" (incf counter (length line)))))
               (#:g2201 (program "sed" "-n" "s/a/_/g ; /__/ p")))
           (pipeline.pipes:with-pipes% (#:pipes2198 2)
             (lastcar
              (mapcar #'pipeline.filters:clean
                      (list
                       (pipeline.filters:spawn #:g2199 :input #:input%2195 :output
                                               (pipeline.pipes:pipe-out
                                                (svref #:pipes2198 0))
                                               :error #:error%2197 :wait nil)
                       (pipeline.filters:spawn #:g2200 :input
                                               (pipeline.pipes:pipe-in
                                                (svref #:pipes2198 0))
                                               :output
                                               (pipeline.pipes:pipe-out
                                                (svref #:pipes2198 1))
                                               :error #:error%2197 :wait nil)
                       (pipeline.filters:spawn #:g2201 :input
                                               (pipeline.pipes:pipe-in
                                                (svref #:pipes2198 1))
                                               :output #:output%2196 :error
                                               #:error%2197 :wait t)))))))))
https://github.com/christophejunke/pipeline

Re: Scripting in Common Lisp

#6
post #2

This is a great guide, and solving quick real problems is how people get started programming in general. I think seeing scsh for the first time made me realize just how good & bad shells are.

> I think seeing scsh for the first time made me realize just how good & bad shells are.

Oddly enough, just last week I was trying to do some scsh-like things with Common Lisp, and I ended up banging my ahead against its case-mapping behaviour (Common Lisp upcases input by default).

There’s definitely an opening for a Lisp version of something like scsh. There’s some tricky stuff to be aware of (e.g. SBCL’s RUN-PROGRAM puts processes in a different process group, which mean C-c does the wrong thing), but done well it could really be awesome.

Re: Scripting in Common Lisp

#8
This is the first time I've seen content provided in Esperanto like this. Pretty cool.

Even cooler is that the Esperanto version seems to be the original, and then I suppose it was translated to English a year later.

Huh, now I see the whole blog defaults to Esperanto.

I wonder how much of the net takes that stand of Esperanto-first.

Re: Scripting in Common Lisp

#9
It's not common lisp, but most of my Emacs use has been as a shell scripting alternative.

Workflow being based around interactive improvement of a script from a simple interactive-macro through to things that are effectively done as shell scripts.

The end result is something that can be run as a shell script, although translating to another language i.e. CL, Ruby, Go, etc. is the usual path for me to make better use / performance.

The old joke about Emacs being an operating system that needs a good editor is on need of a reboot.

Emacs is an interactive computing and development environment with half a dozen good text editors.

Factual isn't as funny though.

Re: Scripting in Common Lisp

#10
I'm somewhat baffled that Hy didn't gain any traction.

Let's review the facts:

- A lot of people love Python.

- Plenty of people love Lisps, afaict with a sizeable overlap with the first group.

- Hy, which is a Lisp on the Python platform, has no popularity whatsoever compared to other Lisps like Clojure.

The heck?

Post reply on HN