-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathinit.m
42 lines (31 loc) · 1.74 KB
/
init.m
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
Unprotect["SetReplace`*"];
(* this is a no-op the first time round, subsequent loads will unload the C++ library first *)
SetReplace`PackageScope`unloadLibrary[];
ClearAll @@ (# <> "*" & /@ Contexts["SetReplace`*"]);
(* Make sure that we don't affect $ContextPath by getting GU, and that we are isolated from
any user contexts *)
BeginPackage["SetReplace`"];
(* This is useful for various purposes, like loading libraries from the 'same place' as the
paclet, and also knowing *where* the loaded code even came from. *)
$SetReplaceRootDirectory = FileNameDrop[$InputFileName, -2];
Needs["GeneralUtilities`"];
(* ensure private symbols we use below don't show up on Global, etc *)
Begin["SetReplace`Private`"];
Block[
(* Temporarily overrule some of the more exotic features of the macro system.
TODO: Fix this upstream when GU is open sourced. *)
{GeneralUtilities`Control`PackagePrivate`$DesugaringRules = {
HoldPattern[$Unreachable] :> Unreachable[$LHSHead],
HoldPattern[ReturnFailed[msg_String, args___]] :> ReturnFailed[MessageName[$LHSHead, msg], args],
HoldPattern[ReturnFailure[msg_String, args___]] :> ReturnFailure[MessageName[$LHSHead, msg], args]
}},
(* All files are loaded lexicographically starting with A0*. Note, "$" comes after "A" in Wolfram Language.
File names starting with digits are not allowed. "_" and "-" are not allowed. *)
Get[First[FileNames["*", FileNameJoin[{$SetReplaceRootDirectory, "Kernel"}]]]];
(* Type system and generators should be initialized after all Kernel files are loaded. *)
SetReplace`PackageScope`initializeTypeSystem[];
SetReplace`PackageScope`initializeSystemGenerators[];
];
End[];
EndPackage[];
SetAttributes[#, {Protected, ReadProtected}] & /@ Evaluate @ Names @ "SetReplace`*";