What do you think are the top ten language constructs in Lisp?
Please don't answer in terms of concepts, but try to restrict
yourself to those statements you really use to cope with your
daily work.
Curious why I'm asking this question? In spite of all requirements
engineering effort we know exactly *how* to solve problems
with computer languages but know fairly, *what* we're doing
during this process.
Regards
Bruno Gustavs
"Bruno Gustavs" <········@ch.sibt.com> writes:
> What do you think are the top ten language constructs in Lisp?
I didn't spend a lot of thought on this, but these come to mind.
There are more than 10. And I'm sure I left some out. Oh well.
Rich language...
defmacro unwind-protect mapcar getf restart-case
defmethod funcall loop destructuring-bind with-open-file
setf typep format handler-bind with-output-to-string
Kent M Pitman <······@world.std.com> writes:
> "Bruno Gustavs" <········@ch.sibt.com> writes:
>
> > What do you think are the top ten language constructs in Lisp?
>
> I didn't spend a lot of thought on this, but these come to mind.
> There are more than 10. And I'm sure I left some out. Oh well.
> Rich language...
>
> defmacro unwind-protect mapcar getf restart-case
> defmethod funcall loop destructuring-bind with-open-file
> setf typep format handler-bind with-output-to-string
I have to ask...
why mapcar _and_ loop?
_some_ of mine are:
defmacro ; macros
loop ; iteration
cond ; control
defclass ; OO structure
defmethod ; OO functionality
typep ; rich type system
let ; binding
apply ; functional programming
setf ; mutation
dave
David Bakhash <·····@alum.mit.edu> writes:
> Kent M Pitman <······@world.std.com> writes:
>
> > "Bruno Gustavs" <········@ch.sibt.com> writes:
> >
> > > What do you think are the top ten language constructs in Lisp?
> >
[...]
> > defmacro unwind-protect mapcar getf restart-case
> > defmethod funcall loop destructuring-bind with-open-file
> > setf typep format handler-bind with-output-to-string
>
> I have to ask...
>
> why mapcar _and_ loop?
Because they each illustrate a wholly different and independently useful
paradigm. LOOP is specifically about the messy interactions between complex
sets of data traversals, filtering, and accumulation happening at the same
time. When you have only a single one ongoing, MAPCAR is fine and useful,
but LOOP addresses a need not otherwise addressed... even if it is
syntactically tricky in many of the cases where it's most useful.
Hi Bruno,
Bruno Gustavs schrieb in Nachricht <············@pollux.ip-plus.net>...
>What do you think are the top ten language constructs in Lisp?
>Please don't answer in terms of concepts, but try to restrict
>yourself to those statements you really use to cope with your
>daily work.
>
>Curious why I'm asking this question? In spite of all requirements
>engineering effort we know exactly *how* to solve problems
>with computer languages but know fairly, *what* we're doing
>during this process.
for each programming language there is a nucleus that
enables a programmer to implement a turing machine
(and thus be able to solve any computational problem).
I would choose setq, cons, cond, eql as basic functions
and symbol and integer as data types. A couple of
arithmetic functions are necessary, but it'll be
far more than ten.
Greetings,
Joachim
"Bruno Gustavs" <········@ch.sibt.com> writes:
> What do you think are the top ten language constructs in Lisp?
> Please don't answer in terms of concepts, but try to restrict
> yourself to those statements you really use to cope with your daily
> work.
My favorite would have to be UNDWIND-PROTECT. To me, it provides the
missing link between functional and imperative programming, enabling
me to blend the two nicely. But I don't actually _type_ it much,
because it's usually wrapped in some macro.
So DEFMACRO would also be a statment that ranks high, as it allows me
to have both readable and complex code at the same time.
--
Frode Vatvedt Fjeld
Bruno Gustavs wrote:
>
> What do you think are the top ten language constructs in Lisp?
> Please don't answer in terms of concepts, but try to restrict
> yourself to those statements you really use to cope with your
> daily work.
>
> Curious why I'm asking this question? In spite of all requirements
> engineering effort we know exactly *how* to solve problems
> with computer languages but know fairly, *what* we're doing
> during this process.
>
> Regards
> Bruno Gustavs
I think defmacro is one of my favorites because you are able to bend
lisp
to whatever language you ever dreamt of. (see "OnLisp" for details ;-)
I also like to use "labels"-recursion for some iteration-problems.
By the use of recursion I'am able to count my iteration-variables
on very different ways (depending on the actual state of the
computation)
In languages like C you have to use break, continue and/or special
in-loop
arithmetics to reach that functionality. With recursion the solution is
short
and descriptive.
It could be that some people will flame me, saying that using recursion
this way
is much to "scheme-like" in a CommonLisp with constructs like "loop" but
I would
tend to say that recursion is much more Lisp-like than most
iteration-constructs.
(That doesn't mean that I don't use the extended loop facility, dolist
or such constructs)
By the use of "labels" the compiler gives me good iterative code out of
this
recursive written code.
(defun make-char-in-seq-p (char-seq)
#'(lambda (a-char)
(find a-char char-seq)))
(defun tokenize-string (str &optional (del '(#\Space))
&key (start 0) (end nil))
(labels ((rec (pos acc)
(if (null pos)
(nreverse acc)
(let ((tpos (position-if (make-char-in-seq-p del)
str :start pos)))
(if (null tpos)
(nreverse (cons (subseq str pos) acc))
(rec (position-if-not (make-char-in-seq-p del)
str :start tpos)
(cons (subseq str pos tpos) acc)))))))
(rec (position-if-not (make-char-in-seq-p del)
str :start start :end end) '())))
This code runs on my cmucl with the same speed and consing like the
equvivalent "loop"
function.
sincerely Yours,
Jochen Schmidt <···@dataheaven.de>
Sorry, but some "funny" person has fiddlet around
with my "personality" Settings in Netscape
To make it clear: I'm _not_ Bill Gates (Thanks god!)
sincerely Yours,
Jochen Schmidt <···@dataheaven.de>