From: arnuld
Subject: Lisp programme to copy file-contents
Date: 
Message-ID: <1153557752.472231.93090@m73g2000cwd.googlegroups.com>
hai folks,

i am trying to write a programme that can copy the contents of one file
to another but i am not able to. here is the code i am able to write :

(defun write-to-file (in-file out-file)
  "this programme copies the contents of one file to another
it takes both files as input arguments"
  (with-open-file
   (i-stream in-file :if-does-not-exist :error)
   (with-open-file
    (o-stream out-file
	      :if-exists :supersede
	      :if-does-not-exist :create)
    (when i-stream
      (loop for line = (read-line i-stream nil)
	    while line do (format o-stream "~A~%" line))))))

here is the error i got on my SBCL 0.9.11 compiler running on Debian
sarge:

;;-------------------------------------------------------------
   * (write-to-file "project-euler.lisp" "z.lisp")

 debugger invoked on a SIMPLE-TYPE-ERROR in thread
  #<THREAD "initial thread" {A68B649}>:
    #<SB-SYS:FD-STREAM for "file
/home/hurd/programming/CODE/lisp/z.lisp" {A6F8871}> is not a character
output stream.

  Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

  restarts (invokable by number or by possibly-abbreviated name):
     0: [ABORT] Exit debugger, returning to top level.

  (SB-KERNEL:ILL-OUT
  #<SB-SYS:FD-STREAM for "file /home/hurd/programming/CODE/lisp/z.lisp"
{A6F8871}>)
  0] 0

 *
;;----------------------------------------------------------------------

how can i make my programme work?

thanks

"arnuld"

From: Rainer Joswig
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <joswig-99AAA6.11192722072006@news-europe.giganews.com>
In article <·······················@m73g2000cwd.googlegroups.com>,
 "arnuld" <·······@gmail.com> wrote:

> hai folks,
> 
> i am trying to write a programme that can copy the contents of one file
> to another but i am not able to. here is the code i am able to write :
> 
> (defun write-to-file (in-file out-file)
>   "this programme copies the contents of one file to another
> it takes both files as input arguments"
>   (with-open-file
>    (i-stream in-file :if-does-not-exist :error)
>    (with-open-file
>     (o-stream out-file
> 	      :if-exists :supersede
> 	      :if-does-not-exist :create)
>     (when i-stream
>       (loop for line = (read-line i-stream nil)
> 	    while line do (format o-stream "~A~%" line))))))
> 
> here is the error i got on my SBCL 0.9.11 compiler running on Debian
> sarge:
> 
> ;;-------------------------------------------------------------
>    * (write-to-file "project-euler.lisp" "z.lisp")
> 
>  debugger invoked on a SIMPLE-TYPE-ERROR in thread
>   #<THREAD "initial thread" {A68B649}>:
>     #<SB-SYS:FD-STREAM for "file
> /home/hurd/programming/CODE/lisp/z.lisp" {A6F8871}> is not a character
> output stream.
> 
>   Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
> 
>   restarts (invokable by number or by possibly-abbreviated name):
>      0: [ABORT] Exit debugger, returning to top level.
> 
>   (SB-KERNEL:ILL-OUT
>   #<SB-SYS:FD-STREAM for "file /home/hurd/programming/CODE/lisp/z.lisp"
> {A6F8871}>)
>   0] 0
> 
>  *
> ;;----------------------------------------------------------------------
> 
> how can i make my programme work?
> 
> thanks
> 
> "arnuld"

Hint: How and where do you say that you want to write to a file?

-- 
http://lispm.dyndns.org/
From: arnuld
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <1153567261.467035.241600@m73g2000cwd.googlegroups.com>
> Hint: How and where do you say that you want to write to a file?

in the *last* line: (format o-stream "~A~%" line), where o-stream is
the stream connected to "out-file" which i opened for writing in the
middle of code.

if i use (format t ....) instead of (format o-stream....) then it
prints all the contents of file onto my REPL (i.e. it does what is
expected).
From: Rainer Joswig
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <C0E7D8C0.476A7%joswig@lisp.de>
Am 22.07.2006 13:21 Uhr schrieb "arnuld" unter <·······@gmail.com> in
························@m73g2000cwd.googlegroups.com:

>> Hint: How and where do you say that you want to write to a file?
> 
> in the *last* line: (format o-stream "~A~%" line),

No, there you are writing to a stream. Most unefficient, btw.

> where o-stream is
> the stream connected to "out-file" which i opened for writing in the
> middle of code.

Where did you open it for writing? Look closer. You opened the file,
but not for writing.
 
> if i use (format t ....) instead of (format o-stream....) then it
> prints all the contents of file onto my REPL (i.e. it does what is
> expected).
> 
From: Christophe Rhodes
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <sqslktvqej.fsf@cam.ac.uk>
"arnuld" <·······@gmail.com> writes:

> i am trying to write a programme that can copy the contents of one file
> to another but i am not able to. here is the code i am able to write :
>
> (defun write-to-file (in-file out-file)
>   "this programme copies the contents of one file to another
> it takes both files as input arguments"
>   (with-open-file
>    (i-stream in-file :if-does-not-exist :error)
>    (with-open-file
>     (o-stream out-file
> 	      :if-exists :supersede
> 	      :if-does-not-exist :create)
>     (when i-stream
>       (loop for line = (read-line i-stream nil)
> 	    while line do (format o-stream "~A~%" line))))))
>
> how can i make my programme work?

There's quite a lot wrong with this.  Most superficially, the
indentation is wrong in the bodies of each WITH-OPEN-FILE (and
additionally you've used literal tabs, so my quoted version looks even
more wrong).

Another thing that is wrong is that you're not sorting out the
directionality of your streams properly.  That's what the error
message is telling you: that a stream you did an output operation on
is not an output stream.

  #<SB-SYS:FD-STREAM for "file /home/hurd/programming/CODE/lisp/z.lisp" {A6F8871}> 
  is not a character output stream.
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

So at the very least you should ensure that you create an output
stream for output operations.

Thirdly, depending on the contents of your files, you may encounter
problems in converting from a sequence of octets (which is what the
files contain, on POSIXish operating systems) to a sequence of
characters.  Since you are not actually using the characters in the
Lisp program (except to convert them straight back into octets), you
might as well work with octets throughout.  This will have the small
bonus of admitting a more efficient implementation, where you reuse a
memory buffer rather than creating throwaway garbage.

Christophe
From: arnuld
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <1153568012.774076.162740@m79g2000cwm.googlegroups.com>
Christophe Rhodes wrote:

> Another thing that is wrong is that you're not sorting out the
> directionality of your streams properly.  That's what the error
> message is telling you: that a stream you did an output operation on
> is not an output stream.
>
>   #<SB-SYS:FD-STREAM for "file /home/hurd/programming/CODE/lisp/z.lisp" {A6F8871}>
>   is not a character output stream.
>   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> So at the very least you should ensure that you create an output
> stream for output operations.


OOh.... one big fool i am :-(, opening a file for writing without
giving any "direction" to "with-open-file" .

this shows that i am still a theoretical-man, not a practical
programmer.

i added the necessary code & of course, it is working.


> Thirdly, depending on the contents of your files, you may encounter
> problems in converting from a sequence of octets (which is what the
> files contain, on POSIXish operating systems) to a sequence of
> characters.  Since you are not actually using the characters in the
> Lisp program (except to convert them straight back into octets), you
> might as well work with octets throughout.  This will have the small
> bonus of admitting a more efficient implementation, where you reuse a
> memory buffer rather than creating throwaway garbage.
>

i did not get this ( i mean "octets"), which again show i am a "kid" in
the programmer's heaven. sadly, i always thought the opposite.

thanks Christophe 


"arnuld"
From: Pascal Bourguignon
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <874px9ybvo.fsf@thalassa.informatimago.com>
"arnuld" <·······@gmail.com> writes:
>> Thirdly, depending on the contents of your files, you may encounter
>> problems in converting from a sequence of octets (which is what the
>> files contain, on POSIXish operating systems) to a sequence of
>> characters.  Since you are not actually using the characters in the
>> Lisp program (except to convert them straight back into octets), you
>> might as well work with octets throughout.  This will have the small
>> bonus of admitting a more efficient implementation, where you reuse a
>> memory buffer rather than creating throwaway garbage.
>>
>
> i did not get this ( i mean "octets"), which again show i am a "kid" in
> the programmer's heaven. sadly, i always thought the opposite.

By default, lisp files are text files.  A text file is a file
containing characters.  That is, things like aleph, three, e with
accute accent, exclamation point, etc.

Lisp objects are typed, so there's no problem in _lisp_ to manipulate
character objects.  But in a unix (posix) file we can only store
numbers between 0 and 255.  Unix (posix) has no notion of text
file.  So we need to encode the characters into a coded byte stream.

There are several different coding systems for characters.  The first
step in defining a coding system is to specify the set of character we
will encode.  The second step is to define a bijective mapping between
this set of character and a subset of integer numbers. A third step
may be to define a way to encode a sequence of these integer numbers
(that may be bigger than 255) to a sequence of integer numbers between
0 and 255.  Optionnaly, you may define in an additionnal step some
meaning for additionnal codes that are not used so far, for purpose
such as controling output device, of structuring files (defining
records, blocks, etc).

For example, ASCII defines the following set of characters:

SPC  !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /  
 0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?  
 @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O  
 P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _  
 `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o  
 p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~      


ASCII defines the following mapping between characters and numbers:
                                                                
 32 SPC  33  !   34  "   35  #   36  $   37  %   38  &   39  '  
 40  (   41  )   42  *   43  +   44  ,   45  -   46  .   47  /  
 48  0   49  1   50  2   51  3   52  4   53  5   54  6   55  7  
 56  8   57  9   58  :   59  ;   60  <   61  =   62  >   63  ?  
 64  @   65  A   66  B   67  C   68  D   69  E   70  F   71  G  
 72  H   73  I   74  J   75  K   76  L   77  M   78  N   79  O  
 80  P   81  Q   82  R   83  S   84  T   85  U   86  V   87  W  
 88  X   89  Y   90  Z   91  [   92  \   93  ]   94  ^   95  _  
 96  `   97  a   98  b   99  c  100  d  101  e  102  f  103  g  
104  h  105  i  106  j  107  k  108  l  109  m  110  n  111  o  
112  p  113  q  114  r  115  s  116  t  117  u  118  v  119  w  
120  x  121  y  122  z  123  {  124  |  125  }  126  ~          

Since all numbers are between 0 and 255, it uses the identity function
to map them codes to a byte sequence.

Finally, since there's a number of free code, ASCII defines some
control codes:

  0 NUL    1 SOH    2 STX    3 ETX    4 EOT    5 ENQ    6 ACK    7 BEL  
  8 BS     9 TAB   10 LF    11 VT    12 FF    13 CR    14 SO    15 SI   
 16 DLE   17 DC1   18 DC2   19 DC3   20 DC4   21 NAK   22 SYN   23 ETB  
 24 CAN   25 EM    26 SUB   27 ESC   28 FS    29 GS    30 RS    31 US   
 32 SPC   33  !   34  "   35  #   36  $   37  %   38  &   39  '  
 40  (   41  )   42  *   43  +   44  ,   45  -   46  .   47  /  
 48  0   49  1   50  2   51  3   52  4   53  5   54  6   55  7  
 56  8   57  9   58  :   59  ;   60  <   61  =   62  >   63  ?  
 64  @   65  A   66  B   67  C   68  D   69  E   70  F   71  G  
 72  H   73  I   74  J   75  K   76  L   77  M   78  N   79  O  
 80  P   81  Q   82  R   83  S   84  T   85  U   86  V   87  W  
 88  X   89  Y   90  Z   91  [   92  \   93  ]   94  ^   95  _  
 96  `   97  a   98  b   99  c  100  d  101  e  102  f  103  g  
104  h  105  i  106  j  107  k  108  l  109  m  110  n  111  o  
112  p  113  q  114  r  115  s  116  t  117  u  118  v  119  w  
120  x  121  y  122  z  123  {  124  |  125  }  126  ~  127 DEL  

Note however that ASCII still doesn't define anything for bytes
between 128 and 255.



Some coding system such as ISO-8859-1 or the various Unicode coding
systems are defined as extensions of ASCII (but a few (old) are
totally different, and a few are _modifications_ of ASCII). 

The various ISO-8859 coding system define additionnal characters in
the character set, and map them to codes between 160 and 255, and
gives meaning to additionnal control codes between 128 and 159.  

Unicode defines a much bigger character set, and map them to integers
between 0 and 1114111.  Then several way to map these integers to
sequences of bytes are defined, such as UTF-7, UTF-8, UTF-16LE,
UTF-16BE, etc.  One interesting property of UTF-8, is that any
sequence of characters that are in the ASCII character set, when
encoded using the rules of ASCII or the rules of UTF-8, produce the
same byte sequence.  But it may be misleading, because you may try to
read UTF-8 files using the default external format which uses the
ASCII encoding, and it may work most of the time, but when you
encounter a character out of the ASCII set.




Now given that the Common Lisp Standard Character Set is exactly the
ASCII character set (how lucky!),  and that ASCII is used by unix
(posix), it is quite possible that the default EXTERNAL-FORMAT used to
read and write text files in lisp be ASCII encoded lines separated by
a LF control code.

If the file contains a byte between 128 and 255, there's no
corresponding character in the ASCII map, so it will raise an error.
If you try to write a character outside of the ASCIi Character Set,
then there will be no way to encode it and it will raise an error.  If
you try to read a byte between 0 and 31 (excluding 13 or 10, one or
both of which may control the line termination), it may very well
raise an error.

Some implementations may use other encoding and external-format by
default or by configuration, and may map control code to
pseudo-characters to try avoid raising errors, but this is
implementation specific behavior.  Some implementation extend the
ISO-8859-1 coding system to map the control codes to pseudo-characters
so there's a 1-1 correspondance between [0,255] and these character.
Using this external-format on these implementation, you may be able to
copy "safely" binary files. But this is only valid for some very
specific implementations in very specific circumstances.


In conclusion, if you want to copy a file of bytes, you should use
:ELEMENT-TYPE '(UNSIGNED-BYTE 8)  (assuming it does what you want on
your implementation/OS).  If you wnat to copy a text file with a
specific encoding, you must give the implementation specific
:EXTERNAL-FORMAT.  What you've programmed is only guaranteed to work
on "well formed" "text" files, ie. text files produced by the same
lisp implementation on the same system.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Small brave carnivores
Kill pine cones and mosquitoes
Fear vacuum cleaner
From: Rob Warnock
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <xdWdnfM5UIgTd1_ZnZ2dnUVZ_vqdnZ2d@speakeasy.net>
Pascal Bourguignon  <···@informatimago.com> wrote:
+---------------
| By default, lisp files are text files.  A text file is ...
+---------------

What a beautiful tutorial!!  It's a prime example for all of us
to follow when responding to newbies.

Hmmm... This kind of thing would be nice to have available
on a web site [other than Google Groups search!], maybe
[by analogy to CloserLookAtHemlock]:

    http://www.cliki.net/CloserLookAtCharacters

or as one of the topics in:

    http://www.cliki.net/Infrequently%20Asked%20Questions


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Tim X
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <87wta5osyy.fsf@tiger.rapttech.com.au>
····@rpw3.org (Rob Warnock) writes:

> Pascal Bourguignon  <···@informatimago.com> wrote:
> +---------------
> | By default, lisp files are text files.  A text file is ...
> +---------------
>
> What a beautiful tutorial!!  It's a prime example for all of us
> to follow when responding to newbies.
>
> Hmmm... This kind of thing would be nice to have available
> on a web site [other than Google Groups search!], maybe
> [by analogy to CloserLookAtHemlock]:
>
>     http://www.cliki.net/CloserLookAtCharacters
>
> or as one of the topics in:
>
>     http://www.cliki.net/Infrequently%20Asked%20Questions
>
>
> -Rob
>
> -----
> Rob Warnock			<····@rpw3.org>
> 627 26th Avenue			<URL:http://rpw3.org/>
> San Mateo, CA 94403		(650)572-2607
>

I agree. Pascal has provided a very clear straight forward explination
which gives enough detail that the OP can research it more if they
want, but not so much detail it will just confuse him. 

I think it would be a good addition to the CL FAQ Peter S. has been
working on as part of the cl gardeners project.


Tim
-- 
tcross (at) rapttech dot com dot au
From: Larry Clapp
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <slrnec7l81.so6.larry@theclapp.ddts.net>
On 2006-07-23, Rob Warnock <····@rpw3.org> wrote:
> Pascal Bourguignon  <···@informatimago.com> wrote:
> +---------------
>| By default, lisp files are text files.  A text file is ...
> +---------------
>
> What a beautiful tutorial!!  It's a prime example for all of us
> to follow when responding to newbies.
>
> Hmmm... This kind of thing would be nice to have available
> on a web site [other than Google Groups search!], maybe
> [by analogy to CloserLookAtHemlock]:
>
>     http://www.cliki.net/CloserLookAtCharacters

So, what's stopping you?  :)
From: Rob Warnock
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <M8mdnaez6vrLDlnZnZ2dnUVZ_vadnZ2d@speakeasy.net>
Larry Clapp  <·····@theclapp.org> wrote:
+---------------
| Rob Warnock <····@rpw3.org> wrote:
| > Pascal Bourguignon  <···@informatimago.com> wrote:
| > +---------------
| >| By default, lisp files are text files.  A text file is ...
| > +---------------
| >
| > What a beautiful tutorial!!  ...
| > Hmmm... This kind of thing would be nice to have available
| > on a web site [other than Google Groups search!], maybe
| > [by analogy to CloserLookAtHemlock]:
| >     http://www.cliki.net/CloserLookAtCharacters
| 
| So, what's stopping you?  :)
+---------------

1. Common courtesy. If Pascal agrees that his "work" should be
   archived & indexed, I'm sure he can easily cause it to happen
   [even if only by asking someone else to do it, if he's too busy].
   I would not presume to arrogate that decision from him. He might
   have a personal web site that he would prefer to use instead of
   CLiki; he might feel that what he posted here is not up to his
   own personal standards for archiving [despite the above praise]
   and that it needs more work first; etc.

2. Copyright. Creating a "derivative work" from something someone
   posts without explicit permission is both impolite & illegal,
   except for brief "fair use" quotes to establish context, as
   above. Note that the Berne Convention on Copyrights [of which
   the U.S. is, finally, a signatory] no longer requires an explicit
   notice in the work; any creative work is now "born copyrighted"
   by its author.


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Larry Clapp
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <slrnec9oak.2v2.larry@theclapp.ddts.net>
On 2006-07-24, Rob Warnock <····@rpw3.org> wrote:
> Larry Clapp  <·····@theclapp.org> wrote:
> +---------------
>| Rob Warnock <····@rpw3.org> wrote:
>| > Pascal Bourguignon  <···@informatimago.com> wrote:
>| > +---------------
>| >| By default, lisp files are text files.  A text file is ...
>| > +---------------
>| >
>| > What a beautiful tutorial!!  ...
>| > Hmmm... This kind of thing would be nice to have available
>| > on a web site [other than Google Groups search!], maybe
>| > [by analogy to CloserLookAtHemlock]:
>| >     http://www.cliki.net/CloserLookAtCharacters
>| 
>| So, what's stopping you?  :)
> +---------------
>
> 1. Common courtesy. If Pascal agrees that his "work" should be
>    archived & indexed, I'm sure he can easily cause it to happen
>    [even if only by asking someone else to do it, if he's too busy].
>    I would not presume to arrogate that decision from him. He might
>    have a personal web site that he would prefer to use instead of
>    CLiki; he might feel that what he posted here is not up to his
>    own personal standards for archiving [despite the above praise]
>    and that it needs more work first; etc.
>
> 2. Copyright. Creating a "derivative work" from something someone
>    posts without explicit permission is both impolite & illegal,
>    except for brief "fair use" quotes to establish context, as
>    above. Note that the Berne Convention on Copyrights [of which the
>    U.S. is, finally, a signatory] no longer requires an explicit
>    notice in the work; any creative work is now "born copyrighted"
>    by its author.

Well, those are excellent points, and I'm sorry I was so flippant.
Your article just struck me as in the same vein as what Kenny calls
"the Open Source fairy", where "someone should ..." rarely seems to
turn into "I will ...".

In light of the above, I'll rephrase my response more seriously and to
the point: if you (et al) have the time and inclination to add
Pascal's article to CLiki, I think you (et al) should offer to do so.
In the same position, I might say, "Pascal (or whomever), that was
great!  Would you object if someone (possibly me) posted that on
CLiki?"

This might even prompt Pascal (or whomever) to make explicit his
feelings on the matter of other people posting random bits of his
Usenet correspondence on random web sites.  He might say "All rights
explicitly reserved", which would preemptively tell fan-boys like me
to bug off  :) , or he might say "all of my Usenet postings are in the
public domain unless otherwise stated", or he might license them in
some other way.

Or he might say "stop talking about me like I'm not here!"  :)

So, I'll ask: Pascal, would you object if someone (possibly Rob
Warnock :) put your article onto CLiki?

-- Larry
From: Rob Warnock
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <R8KdnT4RY4lOC1jZnZ2dnUVZ_oGdnZ2d@speakeasy.net>
Larry Clapp  <·····@theclapp.org> wrote:
+---------------
| So, I'll ask: Pascal, would you object if someone (possibly Rob
| Warnock :) put your article onto CLiki?
+---------------

As you have probably seen by now, Pascal already took care of it
himself, adding significant additional content in the process,
as well as links to Wikipedia articles on various coding systems:

    http://www.cliki.net/CloserLookAtCharacters

Enjoy!


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Pascal Bourguignon
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <87ejwb2io4.fsf@thalassa.informatimago.com>
····@rpw3.org (Rob Warnock) writes:

> Larry Clapp  <·····@theclapp.org> wrote:
> +---------------
> | Rob Warnock <····@rpw3.org> wrote:
> | > Pascal Bourguignon  <···@informatimago.com> wrote:
> | > +---------------
> | >| By default, lisp files are text files.  A text file is ...
> | > +---------------
> | >
> | > What a beautiful tutorial!!  ...
> | > Hmmm... This kind of thing would be nice to have available
> | > on a web site [other than Google Groups search!], maybe
> | > [by analogy to CloserLookAtHemlock]:
> | >     http://www.cliki.net/CloserLookAtCharacters
> | 
> | So, what's stopping you?  :)
> +---------------
>
> 1. Common courtesy. If Pascal agrees that his "work" should be
>    archived & indexed, I'm sure he can easily cause it to happen

I'm doing it.

>    [even if only by asking someone else to do it, if he's too busy].
>    I would not presume to arrogate that decision from him. He might
>    have a personal web site that he would prefer to use instead of
>    CLiki; he might feel that what he posted here is not up to his
>    own personal standards for archiving [despite the above praise]
>    and that it needs more work first; etc.
>
> 2. Copyright. Creating a "derivative work" from something someone
>    posts without explicit permission is both impolite & illegal,
>    except for brief "fair use" quotes to establish context, as
>    above. Note that the Berne Convention on Copyrights [of which
>    the U.S. is, finally, a signatory] no longer requires an explicit
>    notice in the work; any creative work is now "born copyrighted"
>    by its author.

Should we add a Copyleft notice on all our wiki pages?

I guess it could be argued that contribution to wikis contains an
explicit copyleft, but this is not obvious. IANAL.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"Logiciels libres : nourris au code source sans farine animale."
From: Pascal Bourguignon
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <87y7uj123m.fsf@thalassa.informatimago.com>
Pascal Bourguignon <···@informatimago.com> writes:
> ····@rpw3.org (Rob Warnock) writes:
>> | Rob Warnock <····@rpw3.org> wrote:
>> | > What a beautiful tutorial!!  ...
>> | > Hmmm... This kind of thing would be nice to have available
>> | > on a web site [other than Google Groups search!], maybe
>> | > [by analogy to CloserLookAtHemlock]:
>> | >     http://www.cliki.net/CloserLookAtCharacters
>>
>> 1. Common courtesy. If Pascal agrees that his "work" should be
>>    archived & indexed, I'm sure he can easily cause it to happen
>
> I'm doing it.

Done.

http://www.cliki.net/CloserLookAtCharacters

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"Klingon function calls do not have "parameters" -- they have
"arguments" and they ALWAYS WIN THEM."
From: Rob Warnock
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <R8KdnT8RY4kZCFjZnZ2dnUVZ_oGdnZ2d@speakeasy.net>
Pascal Bourguignon  <···@informatimago.com> wrote:
+---------------
| Done.  http://www.cliki.net/CloserLookAtCharacters
+---------------

Thanks!!  Now we can point present & future CL newbies to it...


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Pierre THIERRY
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <pan.2006.07.24.17.21.06.709988@levallois.eu.org>
Le Mon, 24 Jul 2006 16:15:23 +0200, Pascal Bourguignon a écrit :
> I guess it could be argued that contribution to wikis contains an
> explicit copyleft, but this is not obvious. IANAL.

In no manner. Everything contributed to a wiki is copyrighted and all
rights are reserved, theoretically. The fact is, it is somewhat
mandatory that it could continue to be modified, but that doesn't place
the document under any specific license.

That is, I suspect you can't copy or create a derivative work out of a
wiki's content outside of the wiki.

But IANAL either.

Legally,
Nowhere man
-- 
···········@levallois.eu.org
OpenPGP 0xD9D50D8A
From: Russell McManus
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <87psfx6rga.fsf@cl-user.org>
"arnuld" <·······@gmail.com> writes:

> i am trying to write a programme that can copy the contents of one file
> to another

Here's some old code of mine I found laying about...

(defvar *tmp-buffer* (make-array (* 4 1024 1024) :element-type '(unsigned-byte 8)))

(defun copy-file (in-path out-path)
  (with-open-file (in in-path
		      :direction :input
		      :if-does-not-exist :error
		      :element-type '(unsigned-byte 8))
    (ensure-directories-exist out-path)
    (with-open-file (out out-path
			 :direction :output
			 :if-does-not-exist :create
			 :if-exists :supersede
			 :element-type '(unsigned-byte 8))
      (loop for nread = (read-sequence *tmp-buffer* in)
	    do (write-sequence *tmp-buffer* out :end nread)
	    until (zerop nread)))))

-russ
From: Petter Gustad
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <87y7ujwf6m.fsf@filestore.home.gustad.com>
"arnuld" <·······@gmail.com> writes:

> i am trying to write a programme that can copy the contents of one file


(defun copy-file (inpathname outpathname &optional (buffersize #.(* 8 1024)))
  "my standard buffered file copy routine"
  (with-open-file (is inpathname :direction :input)
    (with-open-file (os outpathname :direction :output
                        :if-exists :supersede
                        :if-does-not-exist :create)
      (let ((buffer (make-array buffersize :element-type (stream-element-type is))))
        (do ((nread (read-sequence buffer is) (read-sequence buffer is))
             (total 0 (+ total nread)))
            ((zerop nread) total)
          (write-sequence buffer os :end nread))))))

Petter
-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
From: Lars Brinkhoff
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <85fygosmq2.fsf@junk.nocrew.org>
Petter Gustad <·············@gustad.com> writes:
>(let ((buffer (make-array buffersize :element-type (stream-element-type is))))
>  (do ((nread (read-sequence buffer is) (read-sequence buffer is))
>       (total 0 (+ total nread)))
>      ((zerop nread) total)
>    (write-sequence buffer os :end nread)))

You may want to avoid enclosing DO with LET:

  (do ((buffer (make-array buffersize :element-type (stream-element-type is)))
       (nread (read-sequence buffer is) (read-sequence buffer is))
       (total 0 (+ total nread)))
      ((zerop nread) total)
    (write-sequence buffer os :end nread)))
From: William James
Subject: Re: Lisp programme to copy file-contents
Date: 
Message-ID: <1153785496.753464.195710@i42g2000cwa.googlegroups.com>
arnuld wrote:
> hai folks,
>
> i am trying to write a programme that can copy the contents of one file
> to another but i am not able to. here is the code i am able to write :
>
> (defun write-to-file (in-file out-file)
>   "this programme copies the contents of one file to another
> it takes both files as input arguments"
>   (with-open-file
>    (i-stream in-file :if-does-not-exist :error)
>    (with-open-file
>     (o-stream out-file
> 	      :if-exists :supersede
> 	      :if-does-not-exist :create)
>     (when i-stream
>       (loop for line = (read-line i-stream nil)
> 	    while line do (format o-stream "~A~%" line))))))

In MatzLisp (a.k.a. Ruby):

def copy_file( source_name, dest_name )
  File.open( source_name ) { |source|
    File.open( dest_name, "w" ) { |dest|
      source.each_line { |line|   dest.puts line }
    }
  }
end