delorie.com/archives/browse.cgi | search |
Dmitry: > On Tue, 20 Apr 2021 16:46:34 +0200 (CEST) > "karl AT aspodata DOT se [via geda-user AT delorie DOT com]" <geda-user AT delorie DOT com> > wrote: ... > > (define (readlink file) > > (let* > > ( > > (port (open-input-pipe (string-append "readlink -f " file))) > > (str (read-line port)) > > (close-pipe port) > > ) > > str > > ) > > ) ... > Karl, first of all, I'd like to thank you for not using the "dog's > breakfast coding style" (TM)! :-) What is that ? Is it about all thoose {str|d}angling parentheses... > Being not an expert in the bloody lisp programming language, I wonder > does the call "(close-pipe port)" inside the "let" clause get executed? > (It looks like a variable definition). No, you are right, but I can do it like this (it is nice to have open and close close to each other): (define (readlink file) (let* ( (port (open-input-pipe (string-append "readlink -f " file))) (str (read-line port)) (dummy (close-pipe port)) ) str ) ) but perhaps it is better doing this like: (define (read1pipe cmd) (let* ( (port (open-input-pipe cmd)) (str (read-line port)) ) (close-pipe port) str ) ) (define (readlink file) (read1pipe (string-append "readlink -f " file))) Regards, /Karl Hammar
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |