This file is indexed.

/usr/share/gap/doc/ref/chap9.html is in gap-doc 4r8p8-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>GAP (ref) - Chapter 9: Files and Filenames</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="GAPDoc2HTML" />
<link rel="stylesheet" type="text/css" href="manual.css" />
<script src="manual.js" type="text/javascript"></script>
<script type="text/javascript">overwriteStyle();</script>
</head>
<body class="chap9"  onload="jscontent()">


<div class="chlinktop"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1</a>  <a href="chap2.html">2</a>  <a href="chap3.html">3</a>  <a href="chap4.html">4</a>  <a href="chap5.html">5</a>  <a href="chap6.html">6</a>  <a href="chap7.html">7</a>  <a href="chap8.html">8</a>  <a href="chap9.html">9</a>  <a href="chap10.html">10</a>  <a href="chap11.html">11</a>  <a href="chap12.html">12</a>  <a href="chap13.html">13</a>  <a href="chap14.html">14</a>  <a href="chap15.html">15</a>  <a href="chap16.html">16</a>  <a href="chap17.html">17</a>  <a href="chap18.html">18</a>  <a href="chap19.html">19</a>  <a href="chap20.html">20</a>  <a href="chap21.html">21</a>  <a href="chap22.html">22</a>  <a href="chap23.html">23</a>  <a href="chap24.html">24</a>  <a href="chap25.html">25</a>  <a href="chap26.html">26</a>  <a href="chap27.html">27</a>  <a href="chap28.html">28</a>  <a href="chap29.html">29</a>  <a href="chap30.html">30</a>  <a href="chap31.html">31</a>  <a href="chap32.html">32</a>  <a href="chap33.html">33</a>  <a href="chap34.html">34</a>  <a href="chap35.html">35</a>  <a href="chap36.html">36</a>  <a href="chap37.html">37</a>  <a href="chap38.html">38</a>  <a href="chap39.html">39</a>  <a href="chap40.html">40</a>  <a href="chap41.html">41</a>  <a href="chap42.html">42</a>  <a href="chap43.html">43</a>  <a href="chap44.html">44</a>  <a href="chap45.html">45</a>  <a href="chap46.html">46</a>  <a href="chap47.html">47</a>  <a href="chap48.html">48</a>  <a href="chap49.html">49</a>  <a href="chap50.html">50</a>  <a href="chap51.html">51</a>  <a href="chap52.html">52</a>  <a href="chap53.html">53</a>  <a href="chap54.html">54</a>  <a href="chap55.html">55</a>  <a href="chap56.html">56</a>  <a href="chap57.html">57</a>  <a href="chap58.html">58</a>  <a href="chap59.html">59</a>  <a href="chap60.html">60</a>  <a href="chap61.html">61</a>  <a href="chap62.html">62</a>  <a href="chap63.html">63</a>  <a href="chap64.html">64</a>  <a href="chap65.html">65</a>  <a href="chap66.html">66</a>  <a href="chap67.html">67</a>  <a href="chap68.html">68</a>  <a href="chap69.html">69</a>  <a href="chap70.html">70</a>  <a href="chap71.html">71</a>  <a href="chap72.html">72</a>  <a href="chap73.html">73</a>  <a href="chap74.html">74</a>  <a href="chap75.html">75</a>  <a href="chap76.html">76</a>  <a href="chap77.html">77</a>  <a href="chap78.html">78</a>  <a href="chap79.html">79</a>  <a href="chap80.html">80</a>  <a href="chap81.html">81</a>  <a href="chap82.html">82</a>  <a href="chap83.html">83</a>  <a href="chap84.html">84</a>  <a href="chap85.html">85</a>  <a href="chap86.html">86</a>  <a href="chap87.html">87</a>  <a href="chapBib.html">Bib</a>  <a href="chapInd.html">Ind</a>  </div>

<div class="chlinkprevnexttop">&nbsp;<a href="chap0.html">[Top of Book]</a>&nbsp;  <a href="chap0.html#contents">[Contents]</a>&nbsp;  &nbsp;<a href="chap8.html">[Previous Chapter]</a>&nbsp;  &nbsp;<a href="chap10.html">[Next Chapter]</a>&nbsp;  </div>

<p id="mathjaxlink" class="pcenter"><a href="chap9_mj.html">[MathJax on]</a></p>
<p><a id="X82BCD4297920C903" name="X82BCD4297920C903"></a></p>
<div class="ChapSects"><a href="chap9.html#X82BCD4297920C903">9 <span class="Heading">Files and Filenames</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap9.html#X83D8AAA484EE95D9">9.1 <span class="Heading">Portability</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X87D278437A916905">9.1-1 LastSystemError</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap9.html#X7A4973627A5DB27D">9.2 <span class="Heading">GAP Root Directories</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap9.html#X85030B35865A1080">9.3 <span class="Heading">Directories</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X82B3E24683942597">9.3-1 IsDirectory</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X86A71E927EEC7EAD">9.3-2 Directory</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X8222B1A886E6195E">9.3-3 DirectoryTemporary</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7BAD8036849E8430">9.3-4 DirectoryCurrent</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X87ED469A85343A3C">9.3-5 DirectoriesLibrary</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X808E2C187DD984B4">9.3-6 DirectoriesSystemPrograms</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7B225E5282534EDA">9.3-7 DirectoryContents</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X86F4A32C83B82369">9.3-8 DirectoryDesktop</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7B0D818A808A3481">9.3-9 DirectoryHome</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap9.html#X8545E03E7D651456">9.4 <span class="Heading">File Names</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7E352E1F87060602">9.4-1 <span class="Heading">Filename</span></a>
</span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap9.html#X85EC7D9087C481B0">9.5 <span class="Heading">Special Filenames</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap9.html#X87271FEF86A6A0F9">9.6 <span class="Heading">File Access</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X8269697A7B927AF1">9.6-1 IsExistingFile</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7E156EC886E11BBC">9.6-2 IsReadableFile</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X8412F485796B25F5">9.6-3 IsWritableFile</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X83A1AAD58435FC4C">9.6-4 IsExecutableFile</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7D1BE00F83C4EEE8">9.6-5 IsDirectoryPath</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap9.html#X81A0A4FF842B039B">9.7 <span class="Heading">File Operations</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X8373AC6B7D5F9167">9.7-1 Read</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7824CB7D7D4BAFBC">9.7-2 ReadAsFunction</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X86956C577FFEE1F9">9.7-3 <span class="Heading">PrintTo and AppendTo</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X79813A6686894960">9.7-4 <span class="Heading">LogTo</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7CAB119378B075B7">9.7-5 <span class="Heading">InputLogTo</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7A5591D87EAFA6CC">9.7-6 <span class="Heading">OutputLogTo</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X8241CEAD80415BB9">9.7-7 CrcFile</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7E63ACA38142BE96">9.7-8 RemoveFile</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X79EE267A7FAF28A6">9.7-9 Reread</a></span>
</div></div>
</div>

<h3>9 <span class="Heading">Files and Filenames</span></h3>

<p>Files are identified by filenames, which are represented in <strong class="pkg">GAP</strong> as strings. Filenames can be created directly by the user or a program, but of course this is operating system dependent.</p>

<p>Filenames for some files can be constructed in a system independent way using the following functions. This is done by first getting a directory object for the directory the file shall reside in, and then constructing the filename. However, it is sometimes necessary to construct filenames of files in subdirectories relative to a given directory object. In this case the directory separator is <em>always</em> <code class="code">/</code> even under DOS or MacOS.</p>

<p>Section <a href="chap9.html#X85030B35865A1080"><span class="RefLink">9.3</span></a> describes how to construct directory objects for the common <strong class="pkg">GAP</strong> and system directories. Using the command <code class="func">Filename</code> (<a href="chap9.html#X7E352E1F87060602"><span class="RefLink">9.4-1</span></a>) it is possible to construct a filename pointing to a file in these directories. There are also functions to test for accessibility of files, seeĀ <a href="chap9.html#X87271FEF86A6A0F9"><span class="RefLink">9.6</span></a>.</p>

<p><a id="X83D8AAA484EE95D9" name="X83D8AAA484EE95D9"></a></p>

<h4>9.1 <span class="Heading">Portability</span></h4>

<p>For portability filenames and directory names should be restricted to at most 8 alphanumerical characters optionally followed by a dot <code class="code">.</code> and between 1 and 3 alphanumerical characters. Upper case letters should be avoided because some operating systems do not make any distinction between case, so that <code class="code">NaMe</code>, <code class="code">Name</code> and <code class="code">name</code> all refer to the same file whereas some operating systems are case sensitive. To avoid problems only lower case characters should be used.</p>

<p>Another function which is system-dependent is <code class="func">LastSystemError</code> (<a href="chap9.html#X87D278437A916905"><span class="RefLink">9.1-1</span></a>).</p>

<p><a id="X87D278437A916905" name="X87D278437A916905"></a></p>

<h5>9.1-1 LastSystemError</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; LastSystemError</code>(  )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p><code class="func">LastSystemError</code> returns a record describing the last system error that has occurred. This record contains at least the component <code class="code">message</code> which is a string. This message is, however, highly operating system dependent and should only be used as an informational message for the user.</p>

<p><a id="X7A4973627A5DB27D" name="X7A4973627A5DB27D"></a></p>

<h4>9.2 <span class="Heading">GAP Root Directories</span></h4>

<p>When <strong class="pkg">GAP</strong> is started it determines a list of directories which we call the <em><strong class="pkg">GAP</strong> root directories</em>. In a running <strong class="pkg">GAP</strong> session this list can be found in <code class="code">GAPInfo.RootPaths</code>.</p>

<p>The core part of <strong class="pkg">GAP</strong> knows which files to read relative to its root directories. For example when <strong class="pkg">GAP</strong> wants to read its library file <code class="file">lib/group.gd</code>, it appends this path to each path in <code class="code">GAPInfo.RootPaths</code> until it finds the path of an existing file. The first file found this way is read.</p>

<p>Furthermore, <strong class="pkg">GAP</strong> looks for available packages by examining the subdirectories <code class="file">pkg/</code> in each of the directories in <code class="code">GAPInfo.RootPaths</code>.</p>

<p>The root directories are specified via one or several of the <code class="code">-l paths</code> command line options, see <a href="chap3.html#X782751D5858A6EAF"><span class="RefLink">3.1</span></a>. Furthermore, by default <strong class="pkg">GAP</strong> automatically prepends a user specific <strong class="pkg">GAP</strong> root directory to the list; this can be avoided by calling <strong class="pkg">GAP</strong> with the <code class="code">-r</code> option. The name of this user specific directory depends on your operating system, it can be found in <code class="code">GAPInfo.UserGapRoot</code>. This directory can be used to tell <strong class="pkg">GAP</strong> about personal preferences, to always load some additional code, to install additional packages, or to overwrite some <strong class="pkg">GAP</strong> files. See <a href="chap3.html#X7FD66F977A3B02DF"><span class="RefLink">3.2</span></a> for more information how to do this.</p>

<p><a id="X85030B35865A1080" name="X85030B35865A1080"></a></p>

<h4>9.3 <span class="Heading">Directories</span></h4>

<p><a id="X82B3E24683942597" name="X82B3E24683942597"></a></p>

<h5>9.3-1 IsDirectory</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsDirectory</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;category&nbsp;)</td></tr></table></div>
<p><code class="func">IsDirectory</code> is a category of directories.</p>

<p><a id="X86A71E927EEC7EAD" name="X86A71E927EEC7EAD"></a></p>

<h5>9.3-2 Directory</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Directory</code>( <var class="Arg">string</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
<p>returns a directory object for the string <var class="Arg">string</var>. <code class="func">Directory</code> understands <code class="code">"."</code> for "current directory", that is, the directory in which <strong class="pkg">GAP</strong> was started. It also understands absolute paths.</p>

<p>If the variable <code class="code">GAPInfo.UserHome</code> is defined (this may depend on the operating system) then <code class="func">Directory</code> understands a string with a leading <code class="code">~</code> (tilde) character for a path relative to the user's home directory (but a string beginning with <code class="code">"~other_user"</code> is <em>not</em> interpreted as a path relative to <code class="code">other_user</code>'s home directory, as in a UNIX shell).</p>

<p>Paths are otherwise taken relative to the current directory.</p>

<p><a id="X8222B1A886E6195E" name="X8222B1A886E6195E"></a></p>

<h5>9.3-3 DirectoryTemporary</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; DirectoryTemporary</code>(  )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p>returns a directory object in the category <code class="func">IsDirectory</code> (<a href="chap9.html#X82B3E24683942597"><span class="RefLink">9.3-1</span></a>) for a <em>new</em> temporary directory. This is guaranteed to be newly created and empty immediately after the call to <code class="func">DirectoryTemporary</code>. <strong class="pkg">GAP</strong> will make a reasonable effort to remove this directory upon termination of the <strong class="pkg">GAP</strong> job that created the directory.</p>

<p>If <code class="func">DirectoryTemporary</code> is unable to create a new directory, <code class="keyw">fail</code> is returned. In this case <code class="func">LastSystemError</code> (<a href="chap9.html#X87D278437A916905"><span class="RefLink">9.1-1</span></a>) can be used to get information about the error.</p>

<p>A warning message is given if more than 1000 temporary directories are created in any <strong class="pkg">GAP</strong> session.</p>

<p><a id="X7BAD8036849E8430" name="X7BAD8036849E8430"></a></p>

<h5>9.3-4 DirectoryCurrent</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; DirectoryCurrent</code>(  )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p>returns the directory object for the current directory.</p>

<p><a id="X87ED469A85343A3C" name="X87ED469A85343A3C"></a></p>

<h5>9.3-5 DirectoriesLibrary</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; DirectoriesLibrary</code>( [<var class="Arg">name</var>] )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p><code class="func">DirectoriesLibrary</code> returns the directory objects for the <strong class="pkg">GAP</strong> library <var class="Arg">name</var> as a list. <var class="Arg">name</var> must be one of <code class="code">"lib"</code> (the default), <code class="code">"doc"</code>, <code class="code">"tst"</code>, and so on.</p>

<p>The string <code class="code">""</code> is also legal and with this argument <code class="func">DirectoriesLibrary</code> returns the list of <strong class="pkg">GAP</strong> root directories. The return value of this call differs from <code class="code">GAPInfo.RootPaths</code> in that the former is a list of directory objects and the latter a list of strings.</p>

<p>The directory <var class="Arg">name</var> must exist in at least one of the root directories, otherwise <code class="keyw">fail</code> is returned.</p>

<p>As the files in the <strong class="pkg">GAP</strong> root directories (seeĀ <a href="chap9.html#X7A4973627A5DB27D"><span class="RefLink">9.2</span></a>) can be distributed into different directories in the filespace a list of directories is returned. In order to find an existing file in a <strong class="pkg">GAP</strong> root directory you should pass that list to <code class="func">Filename</code> (<a href="chap9.html#X7E352E1F87060602"><span class="RefLink">9.4-1</span></a>) as the first argument. In order to create a filename for a new file inside a <strong class="pkg">GAP</strong> root directory you should pass the first entry of that list. However, creating files inside the <strong class="pkg">GAP</strong> root directory is not recommended, you should use <code class="func">DirectoryTemporary</code> (<a href="chap9.html#X8222B1A886E6195E"><span class="RefLink">9.3-3</span></a>) instead.</p>

<p><a id="X808E2C187DD984B4" name="X808E2C187DD984B4"></a></p>

<h5>9.3-6 DirectoriesSystemPrograms</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; DirectoriesSystemPrograms</code>(  )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p><code class="func">DirectoriesSystemPrograms</code> returns the directory objects for the list of directories where the system programs reside, as a list. Under UNIX this would usually represent <code class="code">$PATH</code>.</p>

<p><a id="X7B225E5282534EDA" name="X7B225E5282534EDA"></a></p>

<h5>9.3-7 DirectoryContents</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; DirectoryContents</code>( <var class="Arg">dir</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p>This function returns a list of filenames/directory names that reside in the directory <var class="Arg">dir</var>. The argument <var class="Arg">dir</var> can either be given as a string indicating the name of the directory or as a directory object (see <code class="func">IsDirectory</code> (<a href="chap9.html#X82B3E24683942597"><span class="RefLink">9.3-1</span></a>)). It is an error, if such a directory does not exist.</p>

<p>The ordering of the list entries can depend on the operating system.</p>

<p>An interactive way to show the contents of a directory is provided by the function <code class="func">BrowseDirectory</code> (<span class="RefLink">???</span>) from the <strong class="pkg">GAP</strong> package <strong class="pkg">Browse</strong>.</p>

<p><a id="X86F4A32C83B82369" name="X86F4A32C83B82369"></a></p>

<h5>9.3-8 DirectoryDesktop</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; DirectoryDesktop</code>(  )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p>returns a directory object for the users desktop directory as defined on many modern operating systems. The function is intended to provide a cross-platform interface to a directory that is easily accessible by the user. Under Unix systems (including Mac OS X) this will be the <code class="code">Desktop</code> directory in the users home directory if it exists, and the users home directory otherwise. Under Windows it will the users <code class="code">Desktop</code> folder (or the appropriate name under different languages).</p>

<p><a id="X7B0D818A808A3481" name="X7B0D818A808A3481"></a></p>

<h5>9.3-9 DirectoryHome</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; DirectoryHome</code>(  )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p>returns a directory object for the users home directory, defined as a directory in which the user will typically have full read and write access. The function is intended to provide a cross-platform interface to a directory that is easily accessible by the user. Under Unix systems (including Mac OS X) this will be the usual user home directory. Under Windows it will the users <code class="code">My Documents</code> folder (or the appropriate name under different languages).</p>

<p><a id="X8545E03E7D651456" name="X8545E03E7D651456"></a></p>

<h4>9.4 <span class="Heading">File Names</span></h4>

<p><a id="X7E352E1F87060602" name="X7E352E1F87060602"></a></p>

<h5>9.4-1 <span class="Heading">Filename</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Filename</code>( <var class="Arg">dir</var>, <var class="Arg">name</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Filename</code>( <var class="Arg">list-of-dirs</var>, <var class="Arg">name</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
<p>If the first argument is a directory object <var class="Arg">dir</var>, <code class="func">Filename</code> returns the (system dependent) filename as a string for the file with name <var class="Arg">name</var> in the directory <var class="Arg">dir</var>. <code class="func">Filename</code> returns the filename regardless of whether the directory contains a file with name <var class="Arg">name</var> or not.</p>

<p>If the first argument is a list <var class="Arg">list-of-dirs</var> (possibly of length 1) of directory objects, then <code class="func">Filename</code> searches the directories in order, and returns the filename for the file <var class="Arg">name</var> in the first directory which contains a file <var class="Arg">name</var> or <code class="keyw">fail</code> if no directory contains a file <var class="Arg">name</var>.</p>

<p><em>For example</em>, in order to locate the system program <code class="code">date</code> use <code class="func">DirectoriesSystemPrograms</code> (<a href="chap9.html#X808E2C187DD984B4"><span class="RefLink">9.3-6</span></a>) together with the second form of <code class="func">Filename</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">path := DirectoriesSystemPrograms();;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">date := Filename( path, "date" );</span>
"/bin/date"
</pre></div>

<p>In order to locate the library file <code class="file">files.gd</code> use <code class="func">DirectoriesLibrary</code> (<a href="chap9.html#X87ED469A85343A3C"><span class="RefLink">9.3-5</span></a>) together with the second form of <code class="func">Filename</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">path := DirectoriesLibrary();;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Filename( path, "files.gd" );</span>
"./lib/files.gd"
</pre></div>

<p>In order to construct filenames for new files in a temporary directory use <code class="func">DirectoryTemporary</code> (<a href="chap9.html#X8222B1A886E6195E"><span class="RefLink">9.3-3</span></a>) together with the first form of <code class="func">Filename</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">tmpdir := DirectoryTemporary();;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Filename( [ tmpdir ], "file.new" );</span>
fail
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Filename( tmpdir, "file.new" );</span>
"/var/tmp/tmp.0.021738.0001/file.new"
</pre></div>

<p><a id="X85EC7D9087C481B0" name="X85EC7D9087C481B0"></a></p>

<h4>9.5 <span class="Heading">Special Filenames</span></h4>

<p>The special filename <code class="code">"*stdin*"</code> denotes the standard input, i.e., the stream through which the user enters commands to <strong class="pkg">GAP</strong>. The exact behaviour of reading from <code class="code">"*stdin*"</code> is operating system dependent, but usually the following happens. If <strong class="pkg">GAP</strong> was started with no input redirection, statements are read from the terminal stream until the user enters the end of file character, which is usually <strong class="button">Ctrl-D</strong>. Note that terminal streams are special, in that they may yield ordinary input <em>after</em> an end of file. Thus when control returns to the main read-eval-print loop the user can continue with <strong class="pkg">GAP</strong>. If <strong class="pkg">GAP</strong> was started with an input redirection, statements are read from the current position in the input file up to the end of the file. When control returns to the main read eval view loop the input stream will still return end of file, and <strong class="pkg">GAP</strong> will terminate.</p>

<p>The special filename <code class="code">"*errin*"</code> denotes the stream connected to the UNIX <code class="code">stderr</code> output. This stream is usually connected to the terminal, even if the standard input was redirected, unless the standard error stream was also redirected, in which case opening of <code class="code">"*errin*"</code> fails.</p>

<p>The special filename <code class="code">"*stdout*"</code> can be used to print to the standard output.</p>

<p>The special filename <code class="code">"*errout*"</code> can be used to print to the standard error output file, which is usually connected to the terminal, even if the standard output was redirected.</p>

<p><a id="X87271FEF86A6A0F9" name="X87271FEF86A6A0F9"></a></p>

<h4>9.6 <span class="Heading">File Access</span></h4>

<p>When the following functions return <code class="keyw">false</code> one can use <code class="func">LastSystemError</code> (<a href="chap9.html#X87D278437A916905"><span class="RefLink">9.1-1</span></a>) to find out the reason (as provided by the operating system), see the examples.</p>

<p><a id="X8269697A7B927AF1" name="X8269697A7B927AF1"></a></p>

<h5>9.6-1 IsExistingFile</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsExistingFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p><code class="func">IsExistingFile</code> returns <code class="keyw">true</code> if a file with the filename <var class="Arg">filename</var> exists and can be seen by the <strong class="pkg">GAP</strong> process. Otherwise <code class="keyw">false</code> is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsExistingFile( "/bin/date" );     # file `/bin/date' exists</span>
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsExistingFile( "/bin/date.new" ); # non existing `/bin/date.new'</span>
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsExistingFile( "/bin/date/new" ); # `/bin/date' is not a directory</span>
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">LastSystemError().message;</span>
"Not a directory"
</pre></div>

<p><a id="X7E156EC886E11BBC" name="X7E156EC886E11BBC"></a></p>

<h5>9.6-2 IsReadableFile</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsReadableFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p><code class="func">IsReadableFile</code> returns <code class="keyw">true</code> if a file with the filename <var class="Arg">filename</var> exists <em>and</em> the <strong class="pkg">GAP</strong> process has read permissions for the file, or <code class="keyw">false</code> if this is not the case.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsReadableFile( "/bin/date" );     # file `/bin/date' is readable</span>
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsReadableFile( "/bin/date.new" ); # non-existing `/bin/date.new'</span>
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">LastSystemError().message;        </span>
"No such file or directory"
</pre></div>

<p><a id="X8412F485796B25F5" name="X8412F485796B25F5"></a></p>

<h5>9.6-3 IsWritableFile</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsWritableFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p><code class="func">IsWritableFile</code> returns <code class="keyw">true</code> if a file with the filename <var class="Arg">filename</var> exists <em>and</em> the <strong class="pkg">GAP</strong> process has write permissions for the file, or <code class="keyw">false</code> if this is not the case.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsWritableFile( "/bin/date" );  # file `/bin/date' is not writable</span>
false
</pre></div>

<p><a id="X83A1AAD58435FC4C" name="X83A1AAD58435FC4C"></a></p>

<h5>9.6-4 IsExecutableFile</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsExecutableFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p><code class="func">IsExecutableFile</code> returns <code class="keyw">true</code> if a file with the filename <var class="Arg">filename</var> exists <em>and</em> the <strong class="pkg">GAP</strong> process has execute permissions for the file, or <code class="keyw">false</code> if this is not the case. Note that execute permissions do not imply that it is possible to execute the file, e.g., it may only be executable on a different machine.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsExecutableFile( "/bin/date" );   # ... but executable</span>
true
</pre></div>

<p><a id="X7D1BE00F83C4EEE8" name="X7D1BE00F83C4EEE8"></a></p>

<h5>9.6-5 IsDirectoryPath</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsDirectoryPath</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p><code class="func">IsDirectoryPath</code> returns <code class="keyw">true</code> if the file with the filename <var class="Arg">filename</var> exists <em>and</em> is a directory, and <code class="keyw">false</code> otherwise. Note that this function does not check if the <strong class="pkg">GAP</strong> process actually has write or execute permissions for the directory. You can use <code class="func">IsWritableFile</code> (<a href="chap9.html#X8412F485796B25F5"><span class="RefLink">9.6-3</span></a>), resp. <code class="func">IsExecutableFile</code> (<a href="chap9.html#X83A1AAD58435FC4C"><span class="RefLink">9.6-4</span></a>) to check such permissions.</p>

<p><a id="X81A0A4FF842B039B" name="X81A0A4FF842B039B"></a></p>

<h4>9.7 <span class="Heading">File Operations</span></h4>

<p><a id="X8373AC6B7D5F9167" name="X8373AC6B7D5F9167"></a></p>

<h5>9.7-1 Read</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Read</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
<p>reads the input from the file with the filename <var class="Arg">filename</var>, which must be given as a string.</p>

<p><code class="func">Read</code> first opens the file <var class="Arg">filename</var>. If the file does not exist, or if <strong class="pkg">GAP</strong> cannot open it, e.g., because of access restrictions, an error is signalled.</p>

<p>Then the contents of the file are read and evaluated, but the results are not printed. The reading and evaluations happens exactly as described for the main loop (see <a href="chap6.html#X81667F568237B232"><span class="RefLink">6.1</span></a>).</p>

<p>If a statement in the file causes an error a break loop is entered (seeĀ <a href="chap6.html#X8593B49F8705B486"><span class="RefLink">6.4</span></a>). The input for this break loop is not taken from the file, but from the input connected to the <code class="code">stderr</code> output of <strong class="pkg">GAP</strong>. If <code class="code">stderr</code> is not connected to a terminal, no break loop is entered. If this break loop is left with <code class="keyw">quit</code> (or <strong class="button">Ctrl-D</strong>), <strong class="pkg">GAP</strong> exits from the <code class="func">Read</code> command, and from all enclosing <code class="func">Read</code> commands, so that control is normally returned to an interactive prompt. The <code class="keyw">QUIT</code> statement (seeĀ <a href="chap6.html#X83704B1080FD9B40"><span class="RefLink">6.7</span></a>) can also be used in the break loop to exit <strong class="pkg">GAP</strong> immediately.</p>

<p>Note that a statement must not begin in one file and end in another. I.e., <em>eof</em> (<em>e</em>nd-<em>o</em>f-<em>f</em>ile) is not treated as whitespace, but as a special symbol that must not appear inside any statement.</p>

<p>Note that one file may very well contain a read statement causing another file to be read, before input is again taken from the first file. There is an upper limit of 15 on the number of files that may be open simultaneously.</p>

<p><a id="X7824CB7D7D4BAFBC" name="X7824CB7D7D4BAFBC"></a></p>

<h5>9.7-2 ReadAsFunction</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReadAsFunction</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
<p>reads the file with filename <var class="Arg">filename</var> as a function and returns this function.</p>

<p><em>Example</em></p>

<p>Suppose that the file <code class="file">/tmp/example.g</code> contains the following</p>


<div class="example"><pre>
local a;

a := 10;
return a*10;
</pre></div>

<p>Reading the file as a function will not affect a global variable <code class="code">a</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a := 1;</span>
1
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ReadAsFunction("/tmp/example.g")();</span>
100
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a;</span>
1
</pre></div>

<p><a id="X86956C577FFEE1F9" name="X86956C577FFEE1F9"></a></p>

<h5>9.7-3 <span class="Heading">PrintTo and AppendTo</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; PrintTo</code>( <var class="Arg">filename</var>[, <var class="Arg">obj1</var>, <var class="Arg">...</var>] )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AppendTo</code>( <var class="Arg">filename</var>[, <var class="Arg">obj1</var>, <var class="Arg">...</var>] )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p><code class="func">PrintTo</code> works like <code class="func">Print</code> (<a href="chap6.html#X7AFA64D97A1F39A3"><span class="RefLink">6.3-4</span></a>), except that the arguments <var class="Arg">obj1</var>, <span class="SimpleMath">...</span> (if present) are printed to the file with the name <var class="Arg">filename</var> instead of the standard output. This file must of course be writable by <strong class="pkg">GAP</strong>. Otherwise an error is signalled. Note that <code class="func">PrintTo</code> will <em>overwrite</em> the previous contents of this file if it already existed; in particular, <code class="func">PrintTo</code> with just the <var class="Arg">filename</var> argument empties that file.</p>

<p><code class="func">AppendTo</code> works like <code class="func">PrintTo</code>, except that the output does not overwrite the previous contents of the file, but is appended to the file.</p>

<p>There is an upper limit of 15 on the number of output files that may be open simultaneously.</p>

<p><em>Note</em> that one should be careful not to write to a logfile (see <code class="func">LogTo</code> (<a href="chap9.html#X79813A6686894960"><span class="RefLink">9.7-4</span></a>)) with <code class="func">PrintTo</code> or <code class="func">AppendTo</code>.</p>

<p><a id="X79813A6686894960" name="X79813A6686894960"></a></p>

<h5>9.7-4 <span class="Heading">LogTo</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; LogTo</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; LogTo</code>(  )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
<p>Calling <code class="func">LogTo</code> with a string <var class="Arg">filename</var> causes the subsequent interaction to be logged to the file with the name <var class="Arg">filename</var>, i.e., everything you see on your terminal will also appear in this file. (<code class="func">LogTo</code> (<a href="chap10.html#X7BF4E44C7D51E085"><span class="RefLink">10.4-5</span></a>) may also be used to log to a stream.) This file must of course be writable by <strong class="pkg">GAP</strong>, otherwise an error is signalled. Note that <code class="func">LogTo</code> will overwrite the previous contents of this file if it already existed.</p>

<p>Called without arguments, <code class="func">LogTo</code> stops logging to a file or stream.</p>

<p><a id="X7CAB119378B075B7" name="X7CAB119378B075B7"></a></p>

<h5>9.7-5 <span class="Heading">InputLogTo</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; InputLogTo</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; InputLogTo</code>(  )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
<p>Calling <code class="func">InputLogTo</code> with a string <var class="Arg">filename</var> causes the subsequent input to be logged to the file with the name <var class="Arg">filename</var>, i.e., everything you type on your terminal will also appear in this file. Note that <code class="func">InputLogTo</code> and <code class="func">LogTo</code> (<a href="chap9.html#X79813A6686894960"><span class="RefLink">9.7-4</span></a>) cannot be used at the same time while <code class="func">InputLogTo</code> and <code class="func">OutputLogTo</code> (<a href="chap9.html#X7A5591D87EAFA6CC"><span class="RefLink">9.7-6</span></a>) can. Note that <code class="func">InputLogTo</code> will overwrite the previous contents of this file if it already existed.</p>

<p>Called without arguments, <code class="func">InputLogTo</code> stops logging to a file or stream.</p>

<p><a id="X7A5591D87EAFA6CC" name="X7A5591D87EAFA6CC"></a></p>

<h5>9.7-6 <span class="Heading">OutputLogTo</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; OutputLogTo</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; OutputLogTo</code>(  )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
<p>Calling <code class="func">OutputLogTo</code> with a string <var class="Arg">filename</var> causes the subsequent output to be logged to the file with the name <var class="Arg">filename</var>, i.e., everything <strong class="pkg">GAP</strong> prints on your terminal will also appear in this file. Note that <code class="func">OutputLogTo</code> and <code class="func">LogTo</code> (<a href="chap9.html#X79813A6686894960"><span class="RefLink">9.7-4</span></a>) cannot be used at the same time while <code class="func">InputLogTo</code> (<a href="chap9.html#X7CAB119378B075B7"><span class="RefLink">9.7-5</span></a>) and <code class="func">OutputLogTo</code> can. Note that <code class="func">OutputLogTo</code> will overwrite the previous contents of this file if it already existed.</p>

<p>Called without arguments, <code class="func">OutputLogTo</code> stops logging to a file or stream.</p>

<p><a id="X8241CEAD80415BB9" name="X8241CEAD80415BB9"></a></p>

<h5>9.7-7 CrcFile</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; CrcFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p>CRC (cyclic redundancy check) numbers provide a certain method of doing checksums. They are used by <strong class="pkg">GAP</strong> to check whether files have changed.</p>

<p><code class="func">CrcFile</code> computes a checksum value for the file with filename <var class="Arg">filename</var> and returns this value as an integer. The function returns <code class="keyw">fail</code> if a system error occurred, say, for example, if <var class="Arg">filename</var> does not exist. In this case the function <code class="func">LastSystemError</code> (<a href="chap9.html#X87D278437A916905"><span class="RefLink">9.1-1</span></a>) can be used to get information about the error.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">CrcFile( "lib/morpheus.gi" );</span>
2705743645
</pre></div>

<p><a id="X7E63ACA38142BE96" name="X7E63ACA38142BE96"></a></p>

<h5>9.7-8 RemoveFile</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; RemoveFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<p>will remove the file with filename <var class="Arg">filename</var> and returns <code class="keyw">true</code> in case of success. The function returns <code class="keyw">fail</code> if a system error occurred, for example, if your permissions do not allow the removal of <var class="Arg">filename</var>. In this case the function <code class="func">LastSystemError</code> (<a href="chap9.html#X87D278437A916905"><span class="RefLink">9.1-1</span></a>) can be used to get information about the error.</p>

<p><a id="X79EE267A7FAF28A6" name="X79EE267A7FAF28A6"></a></p>

<h5>9.7-9 Reread</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Reread</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; REREADING</code></td><td class="tdright">(&nbsp;global variable&nbsp;)</td></tr></table></div>
<p>In general, it is not possible to read the same <strong class="pkg">GAP</strong> library file twice, or to read a compiled version after reading a <strong class="pkg">GAP</strong> version, because crucial global variables are made read-only (see <a href="chap4.html#X816FBEEA85782EC2"><span class="RefLink">4.9</span></a>) and filters and methods are added to global tables.</p>

<p>A partial solution to this problem is provided by the function <code class="func">Reread</code> (and related functions <code class="code">RereadLib</code> etc.). <code class="code">Reread( <var class="Arg">filename</var> )</code> sets the global variable <code class="func">REREADING</code> to <code class="keyw">true</code>, reads the file named by <var class="Arg">filename</var> and then resets <code class="func">REREADING</code>. Various system functions behave differently when <code class="func">REREADING</code> is set to <code class="keyw">true</code>. In particular, assignment to read-only global variables is permitted, calls to <code class="func">NewRepresentation</code> (<a href="chap79.html#X7CC8106F809E15CF"><span class="RefLink">79.2-1</span></a>) and <code class="func">NewInfoClass</code> (<a href="chap7.html#X7AA1A1CF79F20790"><span class="RefLink">7.4-1</span></a>) with parameters identical to those of an existing representation or info class will return the existing object, and methods installed with <code class="func">InstallMethod</code> (<a href="chap78.html#X837EFDAB7BEF290B"><span class="RefLink">78.2-1</span></a>) may sometimes displace existing methods.</p>

<p>This function may not entirely produce the intended results, especially if what has changed is the super-representation of a representation or the requirements of a method. In these cases, it is necessary to restart <strong class="pkg">GAP</strong> to read the modified file.</p>

<p>An additional use of <code class="func">Reread</code> is to load the compiled version of a file for which the <strong class="pkg">GAP</strong> language version had previously been read (or perhaps was included in a saved workspace). See <a href="chap76.html#X85672DDD7D34D5F0"><span class="RefLink">76.3-10</span></a> and <a href="chap3.html#X7CB282757ACB1C09"><span class="RefLink">3.3</span></a> for more information.</p>

<p>It is not advisable to use <code class="func">Reread</code> programmatically. For example, if a file that contains calls to <code class="func">Reread</code> is read with <code class="func">Reread</code> then <code class="func">REREADING</code> may be reset too early.</p>


<div class="chlinkprevnextbot">&nbsp;<a href="chap0.html">[Top of Book]</a>&nbsp;  <a href="chap0.html#contents">[Contents]</a>&nbsp;  &nbsp;<a href="chap8.html">[Previous Chapter]</a>&nbsp;  &nbsp;<a href="chap10.html">[Next Chapter]</a>&nbsp;  </div>


<div class="chlinkbot"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1</a>  <a href="chap2.html">2</a>  <a href="chap3.html">3</a>  <a href="chap4.html">4</a>  <a href="chap5.html">5</a>  <a href="chap6.html">6</a>  <a href="chap7.html">7</a>  <a href="chap8.html">8</a>  <a href="chap9.html">9</a>  <a href="chap10.html">10</a>  <a href="chap11.html">11</a>  <a href="chap12.html">12</a>  <a href="chap13.html">13</a>  <a href="chap14.html">14</a>  <a href="chap15.html">15</a>  <a href="chap16.html">16</a>  <a href="chap17.html">17</a>  <a href="chap18.html">18</a>  <a href="chap19.html">19</a>  <a href="chap20.html">20</a>  <a href="chap21.html">21</a>  <a href="chap22.html">22</a>  <a href="chap23.html">23</a>  <a href="chap24.html">24</a>  <a href="chap25.html">25</a>  <a href="chap26.html">26</a>  <a href="chap27.html">27</a>  <a href="chap28.html">28</a>  <a href="chap29.html">29</a>  <a href="chap30.html">30</a>  <a href="chap31.html">31</a>  <a href="chap32.html">32</a>  <a href="chap33.html">33</a>  <a href="chap34.html">34</a>  <a href="chap35.html">35</a>  <a href="chap36.html">36</a>  <a href="chap37.html">37</a>  <a href="chap38.html">38</a>  <a href="chap39.html">39</a>  <a href="chap40.html">40</a>  <a href="chap41.html">41</a>  <a href="chap42.html">42</a>  <a href="chap43.html">43</a>  <a href="chap44.html">44</a>  <a href="chap45.html">45</a>  <a href="chap46.html">46</a>  <a href="chap47.html">47</a>  <a href="chap48.html">48</a>  <a href="chap49.html">49</a>  <a href="chap50.html">50</a>  <a href="chap51.html">51</a>  <a href="chap52.html">52</a>  <a href="chap53.html">53</a>  <a href="chap54.html">54</a>  <a href="chap55.html">55</a>  <a href="chap56.html">56</a>  <a href="chap57.html">57</a>  <a href="chap58.html">58</a>  <a href="chap59.html">59</a>  <a href="chap60.html">60</a>  <a href="chap61.html">61</a>  <a href="chap62.html">62</a>  <a href="chap63.html">63</a>  <a href="chap64.html">64</a>  <a href="chap65.html">65</a>  <a href="chap66.html">66</a>  <a href="chap67.html">67</a>  <a href="chap68.html">68</a>  <a href="chap69.html">69</a>  <a href="chap70.html">70</a>  <a href="chap71.html">71</a>  <a href="chap72.html">72</a>  <a href="chap73.html">73</a>  <a href="chap74.html">74</a>  <a href="chap75.html">75</a>  <a href="chap76.html">76</a>  <a href="chap77.html">77</a>  <a href="chap78.html">78</a>  <a href="chap79.html">79</a>  <a href="chap80.html">80</a>  <a href="chap81.html">81</a>  <a href="chap82.html">82</a>  <a href="chap83.html">83</a>  <a href="chap84.html">84</a>  <a href="chap85.html">85</a>  <a href="chap86.html">86</a>  <a href="chap87.html">87</a>  <a href="chapBib.html">Bib</a>  <a href="chapInd.html">Ind</a>  </div>

<hr />
<p class="foot">generated by <a href="http://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
</body>
</html>