File: reread.g

package info (click to toggle)
gap 4r10p0-7
  • links: PTS
  • area: main
  • in suites: buster
  • size: 47,392 kB
  • sloc: ansic: 118,475; xml: 54,089; sh: 4,112; perl: 1,654; makefile: 274
file content (128 lines) | stat: -rw-r--r-- 4,368 bytes parent folder | download
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
#############################################################################
##
#W  reread.g                   GAP Library                       Steve Linton
##
##
#Y  Copyright (C)  1996,  Lehrstuhl D für Mathematik,  RWTH Aachen,  Germany
#Y  (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland
#Y  Copyright (C) 2002 The GAP Group
##
##  This file contains the Reread function and its relatives
##  RereadLib, etc.
##
##  Seems rather little for a file by itself, but I can see no other
##  natural home
##


#############################################################################
##
##  <#GAPDoc Label="Reread">
##
##  <ManSection>
##  <Func Name="Reread" Arg='filename'/>
##  <Var Name="REREADING"/>
##
##  <Description>
##  In general, it is not possible to read the same &GAP; library file
##  twice, or to read a compiled version after reading a &GAP; version,
##  because crucial global variables are made read-only
##  (see <Ref Sect="More About Global Variables"/>)
##  and filters and methods are added to global tables.
##  <P/>
##  A partial solution to this problem is provided by the function
##  <Ref Func="Reread"/> (and related functions <C>RereadLib</C> etc.).
##  <C>Reread( <A>filename</A> )</C> sets the global variable
##  <Ref Var="REREADING"/> to <K>true</K>,
##  reads the file named by <A>filename</A> and then resets
##  <Ref Var="REREADING"/>.
##  Various system functions behave differently when <Ref Var="REREADING"/>
##  is set to <K>true</K>.
##  In particular, assignment to read-only global variables is permitted,
##  calls to <Ref Func="NewRepresentation"/>
##  and <Ref Func="NewInfoClass"/> with parameters identical to those
##  of an existing representation or info class will return the existing
##  object, and methods installed with
##  <Ref Func="InstallMethod"/> may sometimes displace
##  existing methods.
##  <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 &GAP; to read the modified file.
##  <P/>
##  An additional use of <Ref Func="Reread"/> is to load the compiled version
##  of a file for which the &GAP; language version had previously been read
##  (or perhaps was included in a saved workspace).
##  See <Ref Label="Kernel modules"/> and
##  <Ref Sect="Saving and Loading a Workspace"/> for more information.
##  <P/>
##  It is not advisable to use <Ref Func="Reread"/> programmatically.
##  For example, if a file that contains calls to <Ref Func="Reread"/>
##  is read with <Ref Func="Reread"/> then <Ref Var="REREADING"/> may be
##  reset too early.
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
BindGlobal("Reread",
        function(arg)
    local res;
    MakeReadWriteGlobal("REREADING");
    REREADING := true;
    MakeReadOnlyGlobal("REREADING");
    if LEN_LIST(arg) > 1 then
        res := CallFuncList( Read, arg );
    else
        CallFuncList( Read, arg );
    fi;
    MakeReadWriteGlobal("REREADING");
    REREADING := false;
    MakeReadOnlyGlobal("REREADING");
    if LEN_LIST(arg) > 1 then
        return res;
    fi;
end);


BindGlobal("RereadAndCheckFunc", 
        function( arg )
    local func;
    func := CallFuncList(ReadAndCheckFunc, arg);
    return function( arg )
        local res;
        MakeReadWriteGlobal("REREADING");
        REREADING := true;
        MakeReadOnlyGlobal("REREADING");
        if LEN_LIST(arg) > 1 then
            res := CallFuncList(func,arg);
        else
            CallFuncList(func,arg);
        fi;
        MakeReadWriteGlobal("REREADING");
        REREADING := false;
        MakeReadOnlyGlobal("REREADING");
        if LEN_LIST(arg) > 1 then
            return res;
        fi;
    end;
end);

#############################################################################
##
#F  RereadLib( <name> ) . . . . . . . . . . . . . . . . . . . . . library files
##
BIND_GLOBAL("RereadLib",RereadAndCheckFunc("lib"));


#############################################################################
##
#F  RereadGrp( <name> ) . . . . . . . . . . . . . . . . . . group library files
##
BIND_GLOBAL("RereadGrp",RereadAndCheckFunc("grp"));
    

#############################################################################
##
#E