Re: Reading pipe from *standard-input*?
Sam Steingold <[email protected]> Thu, 23 Mar 2017 12:11:19 -0400
| Newsgroups | gmane.lisp.clisp.general |
|---|---|
| Message-ID | <[email protected]> |
> * Jean Louis <[email protected]> [2017-03-23 18:24:07 +0300]: > > On Thu, Mar 23, 2017 at 10:59:10AM -0400, Sam Steingold wrote: >> > (defun main nil >> >> It is extremely unidiomatic to use "nil" for arglist. >> `(defun main () ...)` looks much better. > > It says in documentation that empty list and nil is same thing. Of course it is. > Anyway it works. Of course it does. > You have different experience, and you get surprised what > people write there for a code, who are mostly separate from other > world, like me now in Uganda. Computer programming transcends geography. Coding styles helps people understand each other's code. If you want people to look at your code, you should follow the accepted coding style, including indentation &c. Tomato is a fruit. Will you put it in a fruit salad? :-) >> > (let ((input (with-open-stream (str *standard-input*) >> > (alexandria.0.dev:read-stream-content-into-string str)))) >> >> why not just read from *standard-input* ? > > (let ((input (with-open-stream (str *standard-input*) why create the stream STR which you are not using? > (loop :for line = (read-line *standard-input* nil nil) > :while line > :do (format t "~A~%" line))))) ;;; I guess this note that the LOOP returns NIL. > ;; one here is not correct > (with-open-file (stream tmp-org :if-exists :supersede :if-does-not-exist :create :external-format "utf-8") > (format stream input)) You should not pass NIL as the format control string. Please see http://clhs.lisp.se/Body/f_format.htm > (shell (format nil "emacs -Q -l ~~/.emacs.d/elpa/org-20170210/org-autoloads.el \"~a\" --batch -f org-mode -f org-md-export-to-markdown --kill" tmp-org)) > (format t (with-open-file (stream tmp-md :direction :input) > (loop :for line = (read-line *standard-input* nil nil) > :while line > :do (format t "~A~%" line)))) again you are passing NIL to FORMAT as the control string. >> it's a very bad idea to pass a string to format as the format string. >> you will get an error if your (alexandria...) returns a string >> containing "~". > > Yes, I see, I had this error once back. So how come you are still making the same error? -- Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1504 http://steingoldpsychology.com http://www.childpsy.net http://no2bds.org http://think-israel.org http://iris.org.il http://thereligionofpeace.com I never said most of what is attributed to me on the Internet! --Einstein ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ clisp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/clisp-list