help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lisp style question


From: Pascal J. Bourguignon
Subject: Re: lisp style question
Date: Fri, 03 Dec 2010 06:22:30 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Katalin Sinkov <lispstylist@gmail.com> writes:

> On Dec 2, 12:50 am, "Frode V. Fjeld" <fr...@netfonds.no> wrote:
>> Katalin Sinkov <lispstyl...@gmail.com> writes:
>> > In the {} world I would return a small table like
>>
>> > width   1
>> > height  2
>> > weight  3
>>
>> Typically in Lisp you'd return either a property or association list.
>>
>> I.e: (WIDTH 1 HEIGHT 2 WEIGHT 3) with accessor GETF,
>>
>> or ((WIDTH . 1) (HEIGHT . 2) (WEIGHT . 3)) with accessor ASSOC.
>>
>> --
>> Frode V. Fjeld
>
> Of all the four or five replies, I found yours most helpful although
> brief. This is perhaps due to me being a beginner, although the
> replies seem very promising and I am desirous of understanding them. I
> have just read the paper by McCarthy and the micro manual.
>
> assoc. and pair. are the most elementary of the functions, although
> not primitive and used in evaluator for working the symbol table.
>
> but beyond this, i could not understand your post.
>
> what is an "assoc list" and "a property list" and their difference ?


It is expected from you that you can use google to find the definitions
of the terms used in our responses.

We won't redefine and re-explain everything for the millionth time, when
it's the most basic thing.

If you used google, eg. to search: a-list lisp
or: p-list lisp
you'd find the "GNU Emacs Lisp Reference Manual" which explains them,
amongst a lot of other references.

In addition to the "GNU Emacs Lisp Reference Manual", you may want to
read a more comprehensive lisp book, such as "Practical Common Lisp" or
"Common Lisp: a Gentle Introduction to Symbolic Computation".  You may
also read the little book "Basic Lisp Techniques" (100 pages).  And for
Common Lisp, you may consult the Common Lisp HyperSpec Reference.
Again, I won't provide the URLs,  use Google.


> what is "setf" and how to write it in terms of the elementary
> functions, car/cdr/cons/quote/cond/atom/eq ?
>
> how to conveniently costruct the list that goes with getf ?
>
> Presently I use the emacs IDE only and restricted to elisp, though i
> can (require 'cl) so what are
> the correponding operation in elisp ?

Do (require 'cl).   It would be silly not to.  Put it at the beginning
of your ~/.emacs file.

Learn how to use emacs to get documentation about the lisp operators.
Command such as apropos, describe-function (C-h f), describe-variable
(C-h v), etc.



> what are the corresponding functions to defclass/defstruct in elisp ?
> I assume people are assuming CL.

defclass and defstruct.


For defclass, you will have to (require 'eieio), which, starting from
emacs 23 is included in the distribution.



> Could you comment a little on the post of Captain Obvious and Pascal
> Bourguignon ?

No, I won't comment on my posts.  And if you wanted to address only
Frode, you should have sent him an email.  (But personnaly, I answer
with much less priorioty to personal emails following up a usenet news
message, the less so when it can be of general interest.



> The former has "values" and the latter has "make-volume" and colons.
> How did the constructor "make-volume" come to be ?

Read the documentation of defstruct.



-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]