"Essential lisp utilities": where are they? - lisp
This is a discussion on "Essential lisp utilities": where are they? - lisp ; Hello,
I recall seeing a library of "essential lisp utilities", but I just
spent a better part of an hour going through cliki, my bookmarks,
installed libraries, and the web, and other than suspects such as
trivial-features, and cannot find ...
-
"Essential lisp utilities": where are they?
Hello,
I recall seeing a library of "essential lisp utilities", but I just
spent a better part of an hour going through cliki, my bookmarks,
installed libraries, and the web, and other than suspects such as
trivial-features, and cannot find it.
The reason is that I just wrote a little macro with-dir
(defmacro with-dir ((new-dir) &body body)
`(let ((old-dir (ext:cd)))
;; (format t "will move to ~a~%" ,new-dir)
(ext:cd ,new-dir)
;; (format t "current dir ~a~%" (ext:cd))
,@body
(ext:cd old-dir)))
that I use on clisp(on cygwin+windows) but I suspect a more robust and
universal one exists somewhere, perhaps in the "essential lisp
utilities".
So, where is that beast?
Thanks,
Mirko
-
Re: "Essential lisp utilities": where are they?
On Oct 31, 9:44am, Mirko.Vuko...@gmail.com wrote:
> Hello,
>
> I recall seeing a library of "essential lisp utilities", but I just
> spent a better part of an hour going through cliki, my bookmarks,
> installed libraries, and the web, and other than suspects such as
> trivial-features, and cannot find it.
>
> The reason is that I just wrote a little macro with-dir
> (defmacro with-dir ((new-dir) &body body)
> `(let ((old-dir (ext:cd)))
> ;; (format t "will move to ~a~%" ,new-dir)
> (ext:cd ,new-dir)
> ;; (format t "current dir ~a~%" (ext:cd))
> ,@body
> (ext:cd old-dir)))
>
> that I use on clisp(on cygwin+windows) but I suspect a more robust and
> universal one exists somewhere, perhaps in the "essential lisp
> utilities".
>
> So, where is that beast?
>
> Thanks,
>
> Mirko
Um, cl-utilities?
Mirko (the other twin)
-
Re: "Essential lisp utilities": where are they?
Mirko.Vukovic@gmail.com wrote:
> Hello,
>
> I recall seeing a library of "essential lisp utilities", but I just
> spent a better part of an hour going through cliki, my bookmarks,
> installed libraries, and the web, and other than suspects such as
> trivial-features, and cannot find it.
>
> The reason is that I just wrote a little macro with-dir
> (defmacro with-dir ((new-dir) &body body)
> `(let ((old-dir (ext:cd)))
> ;; (format t "will move to ~a~%" ,new-dir)
> (ext:cd ,new-dir)
> ;; (format t "current dir ~a~%" (ext:cd))
> ,@body
> (ext:cd old-dir)))
A macro isn't needed for this.
Ruby:
def with_dir new_dir
old_dir = Dir.getwd
Dir.chdir new_dir
yield
Dir.chdir old_dir
end
p Dir.getwd
with_dir( ".." ){ p Dir.getwd }
p Dir.getwd
-
Re: "Essential lisp utilities": where are they?
On Oct 31, 10:06am, "William James" <w_a_x_...@yahoo.com> wrote:
> Mirko.Vuko...@gmail.com wrote:
> > Hello,
>
> > I recall seeing a library of "essential lisp utilities", but I just
> > spent a better part of an hour going through cliki, my bookmarks,
> > installed libraries, and the web, and other than suspects such as
> > trivial-features, and cannot find it.
>
> > The reason is that I just wrote a little macro with-dir
> > (defmacro with-dir ((new-dir) &body body)
> > `(let ((old-dir (ext:cd)))
> > ;; (format t "will move to ~a~%" ,new-dir)
> > (ext:cd ,new-dir)
> > ;; (format t "current dir ~a~%" (ext:cd))
> > ,@body
> > (ext:cd old-dir)))
>
> A macro isn't needed for this.
>
> Ruby:
>
> def with_dir new_dir
> old_dir = Dir.getwd
> Dir.chdir new_dir
> yield
> Dir.chdir old_dir
> end
>
> p Dir.getwd
> with_dir( ".." ){ p Dir.getwd }
> p Dir.getwd
Um, that really was of no help:
- did not answer my question, or improve my answer
- did not even remotely convince me to look into Ruby, which would
entail to a) learn it & b) redo everything I did so far.
-
Re: "Essential lisp utilities": where are they?
On Oct 31, 8:07 am, Andreas Davour <ante...@updateLIKE.uu.HELLse>
wrote:
> "William James" <w_a_x_...@yahoo.com> writes:
> > Mirko.Vuko...@gmail.com wrote:
>
> >> Hello,
>
> >> I recall seeing a library of "essential lisp utilities", but I just
> >> spent a better part of an hour going through cliki, my bookmarks,
> >> installed libraries, and the web, and other than suspects such as
> >> trivial-features, and cannot find it.
>
> >> The reason is that I just wrote a little macro with-dir
> >> (defmacro with-dir ((new-dir) &body body)
> >> `(let ((old-dir (ext:cd)))
> >> ;; (format t "will move to ~a~%" ,new-dir)
> >> (ext:cd ,new-dir)
> >> ;; (format t "current dir ~a~%" (ext:cd))
> >> ,@body
> >> (ext:cd old-dir)))
>
> > A macro isn't needed for this.
>
> > Ruby:
>
> > def with_dir new_dir
> > old_dir = Dir.getwd
> > Dir.chdir new_dir
> > yield
> > Dir.chdir old_dir
> > end
>
> > p Dir.getwd
> > with_dir( ".." ){ p Dir.getwd }
> > p Dir.getwd
>
> William, to post a solution to a problem in a comp.lang.* group in
> another language than the one the group is set up to discuss is counter
> productive and rude. Please don't.
I disagree. In fact, to be strict, his post is relevant in showing
macros are not necessary to the original question, while your poste is
off-topic.
Newsgroups got lots tech geekers like you that makes it suffer.
Further readings:
• Cross-posting & Language Factions
http://xahlee.org/Netiquette_dir/cross-post.html
plain text version follows:
----------------------
Cross-posting & Language Factions
Xah Lee, 2007-03-29
(The following article is originally cross-posted on 2007-04-16 to the
folowing newsgroups: comp.lang.perl.misc, comp.lang.python,
comp.lang.lisp, comp.lang.java.programmer, comp.lang.functional.)
Dear tech geekers,
In the past year i have crossed-posted (e.g. recently What are OOP's
Jargons and Complexities, Is laziness a programer's virtue?, On Java's
Interface (the meaning of interface in computer programing), there are
some controversy, and lots of off-topic and careless following.
I think there are few things today's tech geekers should remind
themselves:
• If you deem something off-topic to “your” newsgroup, and want to
tech-geek by changing the “follow-up group”, start with yourself.
Please do not cross-post yourself, and tweak the follow-up, and
proudly proclaim that you changed the follow-up as a benign gesture.
• Please remind yourself what is on-topic and off-topic. Unless you
are the authority of a online forum, otherwise, netiquette discussion,
policing, are off-topic in general, and only tend to worsen the
forum's quality. This issue is realized in newsgroup communities as
early as early 1990s.
• The facility of cross-posting is a good thing as a progress of
communication technology, and the action of cross-posting is a good
thing with respect to communication. What the common tech-geekers's
sensitivity to cross-posting are due to this collective's lack of
understanding of social aspects of communication. Cross-posting isn't
a problem. The problem is the power-struggling male nature and
defensiveness in propagating the tongues of a tech geeker's own.
Tech-geeker's behavior towards cross-posting over the years did
nothing to enhance the content quality of newsgroups, but engendered
among computing language factions incommunicado, and aided in the
proliferation of unnecessary re-invention (e.g. the likes of Perl,
PHP, Python, Ruby that are essentially the same) and stagnation (e.g.
the lisp camp with their above-it attitude).
If you are a programer of X and is learning Y or wondering about Y,
please do cross-post it. If your article is relevant to X, Y, and Z,
please cross post it. If you are really anti-cross-posting, please use
a online forum that is more specialized with controlled communication,
such as mailing lists, developer's blogs, and website-based forums.
I hope that the computing newsgroups will revive to its ancient nature
of verdant cross communication of quality content, as opposed to
today's rampant messages focused on political in-fighting, mutual
sneering, closed-mindedness, and careless postings.
References:
Tech Geekers versus Spammers
Netiquette Guidelines, 1995, by S Hambridge. (RFC 1855)
http://tools.ietf.org/html/rfc1855
Xah
∑ http://xahlee.org/
☄
-
Re: "Essential lisp utilities": where are they?
xahlee@gmail.com wrote:
> I disagree. In fact, to be strict, his post is relevant in showing
> macros are not necessary to the original question, while your poste is
> off-topic.
For the innocent bystander who doesn't already know that xahlee is a
nut, macros are very necessary to the original question, to abstract
away the boiler plate that lambda would be without:
(do-with-dir "some-dir" (lambda () (something-to-do) ))
(do-with-dir "some-other-dir" (lambda () (something-else-to-do)))
;; always the same -----------^^^^^^^^^^^----------------------^
This is explained in SICP, along with the other kinds of abstraction.
--
__Pascal Bourguignon__
http://www.informatimago.com
-
Re: "Essential lisp utilities": where are they?
William James wrote:
> Mirko.Vukovic@gmail.com wrote:
>
> > Hello,
> >
> > I recall seeing a library of "essential lisp utilities", but I just
> > spent a better part of an hour going through cliki, my bookmarks,
> > installed libraries, and the web, and other than suspects such as
> > trivial-features, and cannot find it.
> >
> > The reason is that I just wrote a little macro with-dir
> > (defmacro with-dir ((new-dir) &body body)
> > `(let ((old-dir (ext:cd)))
> > ;; (format t "will move to ~a~%" ,new-dir)
> > (ext:cd ,new-dir)
> > ;; (format t "current dir ~a~%" (ext:cd))
> > ,@body
> > (ext:cd old-dir)))
>
> A macro isn't needed for this.
>
> Ruby:
>
> def with_dir new_dir
> old_dir = Dir.getwd
> Dir.chdir new_dir
> yield
> Dir.chdir old_dir
> end
>
> p Dir.getwd
> with_dir( ".." ){ p Dir.getwd }
> p Dir.getwd
The handling of the code-block can be more explicit.
def with_dir new_dir, &block
old_dir = Dir.getwd
Dir.chdir new_dir
block.call
Dir.chdir old_dir
end
p Dir.getwd
with_dir( ".." ){ p Dir.getwd }
with_dir( ".." ) do
p Dir.getwd
end
p Dir.getwd
-
Re: "Essential lisp utilities": where are they?
On 31 Okt., 15:06, "William James" <w_a_x_...@yahoo.com> wrote:
> Mirko.Vuko...@gmail.com wrote:
> > Hello,
>
> > I recall seeing a library of "essential lisp utilities", but I just
> > spent a better part of an hour going through cliki, my bookmarks,
> > installed libraries, and the web, and other than suspects such as
> > trivial-features, and cannot find it.
>
> > The reason is that I just wrote a little macro with-dir
> > (defmacro with-dir ((new-dir) &body body)
> > `(let ((old-dir (ext:cd)))
> > ;; (format t "will move to ~a~%" ,new-dir)
> > (ext:cd ,new-dir)
> > ;; (format t "current dir ~a~%" (ext:cd))
> > ,@body
> > (ext:cd old-dir)))
>
> A macro isn't needed for this.
You're wrong.
>
> Ruby:
>
> def with_dir new_dir
> old_dir = Dir.getwd
> Dir.chdir new_dir
> yield
> Dir.chdir old_dir
> end
>
> p Dir.getwd
> with_dir( ".." ){ p Dir.getwd }
> p Dir.getwd
The need for macros is encoded in a special case syntax for blocks
implemented in the Ruby interpreter. The programmer has no chance to
change this syntax like with the different kinds of macros in Common
Lisp.
ciao,
Jochen
-
Re: "Essential lisp utilities": where are they?
William James wrote:
> Mirko.Vukovic@gmail.com wrote:
>> I recall seeing a library of "essential lisp utilities", but I just
>> spent a better part of an hour going through cliki, my bookmarks,
>> installed libraries, and the web, and other than suspects such as
>> trivial-features, and cannot find it.
>>
>> The reason is that I just wrote a little macro with-dir
....
> A macro isn't needed for this.
>
> Ruby:
>
> def with_dir new_dir
> old_dir = Dir.getwd
> Dir.chdir new_dir
> yield
> Dir.chdir old_dir
> end
>
> p Dir.getwd
> with_dir( ".." ){ p Dir.getwd }
> p Dir.getwd
True; same thing in lisp. But the OP didn't want to use a functional
style; he wanted to inline the code. Hence the need for macros.
Your Ruby code translates into lisp that looks something like
(defun with-dir (new-dir f)
(let ((old-dir (ext:cd)))
(ext:cd new-dir)
(unwind-protect
(funcall f)
(ext:cd old-dir))))
(ext:cd)
(with-dir new-dir (lambda () (print (ext:cd))))
(ext:cd)
[untested]
- Daniel
-
Re: "Essential lisp utilities": where are they?
On Oct 31, 5:40 pm, Pascal Bourguignon <p...@informatimago.com> wrote:
> xah...@gmail.com wrote:
> > I disagree. In fact, to be strict, his post is relevant in showing
> > macros are not necessary to the original question, while your poste is
> > off-topic.
>
> For the innocent bystander who doesn't already know that xahlee is a
> nut, macros are very necessary to the original question, to abstract
> away the boiler plate that lambda would be without:
>
> (do-with-dir "some-dir" (lambda () (something-to-do) ))
> (do-with-dir "some-other-dir" (lambda () (something-else-to-do)))
> ;; always the same -----------^^^^^^^^^^^----------------------^
>
> This is explained in SICP, along with the other kinds of abstraction.
Dear Pascal Bourguignon moron,
The issue of my previous post was about against persecuting different
opinions. It is not about, whether William James's Ruby code does or
does not supercede the macros feature of lisp.
On the issue of macros, please note, that it is one of lisp features
that gets lispers giddy, where you can see large amounts of posts
about macros every week. Note that, when a macro system is well
designed and extensive to incorporate pattern matching facilities, the
language becomes a term rewriting system, which is what Mathematica
is.
See also:
http://documents.wolfram.com/mathema...tternMatching/
http://en.wikipedia.org/wiki/Pattern_matching
http://en.wikipedia.org/wiki/Rewriting
http://en.wikipedia.org/wiki/Mathematica
Xah
∑ http://xahlee.org/
☄