axiom-developer
[Top][All Lists]
Advanced

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

RE: [Axiom-developer] Re: learning Lisp


From: Bill Page
Subject: RE: [Axiom-developer] Re: learning Lisp
Date: Mon, 5 Dec 2005 09:38:38 -0500

On December 5, 2005 4:01 AM William Sit wrote:
> ...
> Bill Page wrote:
> > The simplest way to "get into lisp" from within Axiom is the
> > ')fin' command. See page 1018 of the Axiom book (book2.pdf):
> >
> > 1.10 )fin
>
> Ok, that gets me into Boot.

No, that is not quite correct. )fin *does* get you into lisp.
You are in the boot 'package' by default. That is all that the
prompt

  BOOT>

means. You can change to some other package via

  (in-package 'xxx)

  XXX>

In lisp packages provide unique namespaces by prefixing the
package name to symbols so you can write:

BOOT>(setq zzz 1)
1
BOOT>(in-package :xxx)
#<"XXX" package>
XXX>(setq zzz 2)
2
XXX>zzz
2
XXX>(in-package :boot)
#<"BOOT" package>
BOOT>zzz
1
BOOT>

------

So now you have two different symbols boot::zzz and xxx::zzz with
different values.

BOOT>xxx::zzz
2
BOOT>boot::zzz
1

> I was able to type a lisp expression and it got evaluated.
> Now what?

:) well, the rest of lisp, of course! I really strongly
recommend consulting a book such as

http://www.gigamonkeys.com/book/

For information about lisp packages read

http://www.gigamonkeys.com/book/programming-in-the-large-packages-and-symbol
s.html

But you must be aware in a few cases that the version of gcl that
is used in Axiom is not quite ANSI common lisp.

> How do I read in a lisp file to evaluate a list of Lisp
> expressions?

A good place to start reading is here:

http://www.gigamonkeys.com/book/lather-rinse-repeat-a-tour-of-the-repl.html

You need to find out about the lisp command

  (load "hello.lisp")

> Can I create a separate name-space (without having to prefix
> each name with something like myname- )? (something like with
> prefix myname-?)
>

Yes, certainly. See the stuff about packages above.

>
> I downloaded lispbox, as recommended by you all, and
> installed the Windows version. After some tries, I got it
> to start runemacs.exe (there was some problem with paths,
> the usual trouble), and to a *scratch* buffer where it says:
>
> ; This buffer is for notes you don't want to save, and for
> Lisp evaluation.
> ;; If you want to create a file, visit that file with C-x C-f,
> ;; then enter the text in that file's own buffer.
>
> I am not interested in editing in emacs (as a last resort, I
> can cut and paste into an emacs buffer), but rather how to run
> a process (lisp).  As far as I know, it is only an edit buffer.
> Supposedly, lisp is already running? There is no "prompt" to
> enter a lisp expression and everything I entered was treated
> like text.

If you are not an emacs users then I do sympathize with you.
But here again Peter Seibel's book should be a big help to
you.

>
> I did spend some time reading help and Emacs manual, but
> they are all for editing and I got lost quickly.

If you are just getting started with emacs then I certainly
would not recommend that you start by reading the manual. :)
Seriously. It is much better to use a reference that has a
specific purpose like Seibel's book.

>
> Tim wrote:
> > to run a lisp command you can use )lisp.
> > if you want to run a lot of them from the command line do:
> >
> >  --> )lisp (setq $dalymode t)
> > $dalymode says:
> >
> >   if the first character is a '('
> >     then it is lisp
> >     else it is axiom
>
> That is nice. Your instructions are exactly what I was
> looking for. I can read in a file (on Linux, but on Windows,
> there is the path problems). Is there any danger I overwrite
> any system definitions? The functions defined survive after
> (setq $dalymode nil) and another (setq $dalymode t), which is
> nice also. Are these functions then available in Axiom somehow?

Yes but function names in Axiom always have the syntax |name|
with vertical bars on each side.

>
> Bill Page wrote:
> > I have been thinking about adding a section to the MathAction
> > web site specifically about lisp, learning lisp, lisp as
> > used in Axiom etc. If you have any ideas about this as someone
> > who knows Axiom and wants to learn more about lisp, I would
> > be very interested.
>
> That is a very good idea, especially the connection between
> lisp and Axiom.

Good. Then perhaps with your help (This email is already the
right kind of help.) then let's do it.

>
> I think I may be a very bad example since I am very clumsy
> with Linux, Emacs.

As far as I am concerned that makes you both typical and
perfect as an example.

> I prefer to learn by trial and error once I know the mechanics
> of the REPL. I do not worry about the programming aspect or the
> editing aspect, only the interface. So, for me, I think a brief
> description of how the interactive loop goes is most important
> to get me started. (So under the Axiom environment, Tim's
> secret mode instructions is already enough for me.)

I really "hate" that this is a "secret mode". I do not think
there should be any secret modes like this hidden in Axiom. If
it is desirable to be able to input lisp expressions in the
Axiom interpreter, then there should be a simple and open way
to achieve this. For example:

  )set input mode lisp

or something like that.

> Specifically: I suggest the page for learning lisp to include:
>
>  The lisp environment you recommend, and why you recommend it
>  how to start the lisp environment (including installation if
>  not Axiom) how to quit the lisp environment

Because we are talking specifically about lisp in the context
of Axiom and at present there is no recommended way to use "modern"
tools like SLIME in Axiom, I would be content to discuss just the
use of ')fin' and ')set input mode lisp'.

>  how to interactively enter a lisp expression to get it evaluated

Page 1 of any lisp book usually has

(+ 1 1)

>  how to read in a file of lisp expressions and get them evaluated
>  how to save a session and if possible, reload a saved one to
>  continue (recomputing is ok)

We almost covered that above. There is enough additional detail
in chapter 2 of Siebel's book.

>  how to compile lisp libraries and have them loaded at start
>  how to learn about lisp built-in functions
>
> I think these are not specific to lisp at all and people
> should not have to read a lot to start having some fun to
> experiment with a language.

I agree that it is desirable to have enough information on one
web page or two to get started and even to progress to a fairly
deep level in the way lisp is used in Axiom.

> It should be like a new "game": Easy to start playing, harder
> to master. As to learning lisp, there are many books and good
> references and the page may list a recommended few, but this is
> not as important as information on the environment to run lisp.

Agreed.

> It would be nice to have the above available for each lisp
> environment recommended.
>

Unless you really want to learn "modern" lisp, then I think
the lisp modes in Axiom are enough.

Regards,
Bill Page.






reply via email to

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