You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove obsolete paragraph on struct redefinition from FAQ (#59399)
The FAQ for Julia v1.12 and master still contains a paragraph that
explains how to work around the impossibility to redefine a type in a
REPL session. This paragraph is now obsolete thanks to #57253 so I
propose to simply remove it.
(cherry picked from commit 0c1fab4)
Copy file name to clipboardExpand all lines: doc/src/manual/faq.md
-29Lines changed: 0 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,35 +74,6 @@ If memory usage is your concern, you can always replace objects with ones that c
74
74
with `A = nothing`. The memory will be released the next time the garbage collector runs; you can force
75
75
this to happen with [`GC.gc()`](@ref Base.GC.gc). Moreover, an attempt to use `A` will likely result in an error, because most methods are not defined on type `Nothing`.
76
76
77
-
### How can I modify the declaration of a type in my session?
78
-
79
-
Perhaps you've defined a type and then realize you need to add a new field. If you try this at
80
-
the REPL, you get the error:
81
-
82
-
```
83
-
ERROR: invalid redefinition of constant MyType
84
-
```
85
-
86
-
Types in module `Main` cannot be redefined.
87
-
88
-
While this can be inconvenient when you are developing new code, there's an excellent workaround.
89
-
Modules can be replaced by redefining them, and so if you wrap all your new code inside a module
90
-
you can redefine types and constants. You can't import the type names into `Main` and then expect
91
-
to be able to redefine them there, but you can use the module name to resolve the scope. In other
92
-
words, while developing you might use a workflow something like this:
93
-
94
-
```julia
95
-
include("mynewcode.jl") # this defines a module MyModule
96
-
obj1 = MyModule.ObjConstructor(a, b)
97
-
obj2 = MyModule.somefunction(obj1)
98
-
# Got an error. Change something in "mynewcode.jl"
99
-
include("mynewcode.jl") # reload the module
100
-
obj1 = MyModule.ObjConstructor(a, b) # old objects are no longer valid, must reconstruct
101
-
obj2 = MyModule.somefunction(obj1) # this time it worked!
102
-
obj3 = MyModule.someotherfunction(obj2, c)
103
-
...
104
-
```
105
-
106
77
## [Scripting](@id man-scripting)
107
78
108
79
### How do I check if the current file is being run as the main script?
0 commit comments