From: chenyu
Subject: new question, create file in lisp
Date: 
Message-ID: <6143ac23.0311202237.6c98dd76@posting.google.com>
Hi,
I have just started to learn the lisp language. Is there any common
function for "creation file"?


Thank you for your attention.
kind regards/chenyu

From: Stefan Scholl
Subject: Re: new question, create file in lisp
Date: 
Message-ID: <1wrlizlbp7hdr$.dlg@parsec.no-spoon.de>
On 2003-11-21 07:37:22, chenyu wrote:
> I have just started to learn the lisp language. Is there any common
> function for "creation file"?

Should be mentioned in every book. Or in the Hyperspec:
http://www.lispworks.com/reference/HyperSpec/Body/20_.htm
From: Pascal Bourguignon
Subject: Re: new question, create file in lisp
Date: 
Message-ID: <87d6bln43h.fsf@thalassa.informatimago.com>
Stefan Scholl <······@no-spoon.de> writes:

> On 2003-11-21 07:37:22, chenyu wrote:
> > I have just started to learn the lisp language. Is there any common
> > function for "creation file"?
> 
> Should be mentioned in every book. Or in the Hyperspec:
> http://www.lispworks.com/reference/HyperSpec/Body/20_.htm

No. This is  the chapter about Files.  The file create  is done in the
chapter about Streams. Ain't it logical?


-- 
__Pascal_Bourguignon__
http://www.informatimago.com/
From: Pascal Bourguignon
Subject: Re: new question, create file in lisp
Date: 
Message-ID: <87llqambh9.fsf@thalassa.informatimago.com>
·········@hotmail.com (chenyu) writes:

> Hi,
> I have just started to learn the lisp language. Is there any common
> function for "creation file"?

It's not often useful to merely create a file.
(But sometimes it is, witness the touch command in unix).

So, assuming that you don't want to only create the file but also fill
it, that's done  opening a stream. You may use  the OPEN function, or,
since there  will be a time when  you'll be done filling  the file and
you'll be wanting to CLOSE it, you may as well use WITH-OPEN-FILE that
will do everything for you (but the filling):

    (WITH-OPEN-FILE (FILE PATH 
                     :DIRECTION         :OUTPUT 
                     :IF-DOES-NOT-EXIST :CREATE
                     :IF-EXISTS         :ERROR)
        (FORMAT FILE "DATA DATA DATA~%"))


But if you just want the functionality of touch(1), you may do it with:

 (DEFUN TOUCH (PATH)
    (WITH-OPEN-FILE (FILE PATH 
                     :DIRECTION         :OUTPUT 
                     :IF-DOES-NOT-EXIST :CREATE
                     :IF-EXISTS         NIL)))


http://www.lisp.org/HyperSpec/Body/sec_the_streams_dictionary.html

-- 
__Pascal_Bourguignon__
http://www.informatimago.com/
From: Roman Belenov
Subject: Re: new question, create file in lisp
Date: 
Message-ID: <u1xs2nlnn.fsf@intel.com>
·········@hotmail.com (chenyu) writes:

> I have just started to learn the lisp language. Is there any common
> function for "creation file"?

Yes, open function can do it. Read also about with-open-file macro -
it makes file handling safer and easier and is sufficient in many
cases.

-- 
 							With regards, Roman.

Standard disclaimer: I work for them, but I don't speak for them.
From: chenyu
Subject: Re: new question, create file in lisp
Date: 
Message-ID: <6143ac23.0311231845.297a0f89@posting.google.com>
Thank you for everyone's reply.

kind regards/chenyu

Roman Belenov <·············@intel.com> wrote in message news:<·············@intel.com>...
> ·········@hotmail.com (chenyu) writes:
> 
> > I have just started to learn the lisp language. Is there any common
> > function for "creation file"?
> 
> Yes, open function can do it. Read also about with-open-file macro -
> it makes file handling safer and easier and is sufficient in many
> cases.