Skip to main content
22 events
when toggle format what by license comment
Feb 9, 2017 at 6:42 history edited Kuba CC BY-SA 3.0
added 85 characters in body
Feb 9, 2017 at 1:07 vote accept Edmund
Feb 8, 2017 at 13:59 history edited Kuba CC BY-SA 3.0
added 82 characters in body
Feb 8, 2017 at 13:58 comment added Kuba @Edmund That is a very good point!
Feb 8, 2017 at 13:56 comment added Edmund My thoughts are that I would unlock the context to explicitly declare additional variables. If there are unused variable names that are locked then this excludes them from being used. It also seems cleaner not to have the failed symbols lurking around the context once it is unlocked as all symbols should be available when in the unlocked state.
Feb 8, 2017 at 13:51 comment added Kuba @Edmund I would not, if Remove then only those that were locked by this function. Why complicate things? So you can add a Remove procedure just after Unprotecting if you need.
Feb 8, 2017 at 13:47 comment added Edmund I think on unlocking the context I would Remove all Protected symbols in the context that had Definition[_Symbol] === Null. I believe that would restrict the removal to only those symbols protected by the context lock.
Feb 8, 2017 at 7:35 comment added Kuba @Edmund you are requested to clean old comments and give a feedback about the update :)
Feb 6, 2017 at 13:11 comment added rcollyer @kuba not caring is definitely a good stopping point. :)
Feb 6, 2017 at 7:20 comment added Kuba @rcollyer I decided that I don't care and OP probably isn't concered about those symbols being created and the main goal is to find OP's typos in symbols' names :) Yep, AppendTo is not a good practice but here is it more readable and won't harm. And yep, a lot of things can be added, like preventing $LockedContexts from being manually modified but I don't want to overcommit if I don't know if that fits OP needs. Tips on point of course, thanks.
Feb 5, 2017 at 21:29 comment added rcollyer (cont'd) to contextLock[context_: $Context] := ( If[$LockedContexts === <||>, setLocking[]]; $LockedContexts[context] = Lookup[$LockedContexts, context, {}]~Join~{}; context );. Similarly, I'd swap out the Append in setLocking to $LockedContexts[#2] = $LockedContexts[#2]~Join~{#2 <> #1};, but I think that is more aesthetics, than any actual effect. Lastly, I'd have contextUnlock also return context, like I had contextLock return. Better feedback to the user.
Feb 5, 2017 at 21:27 comment added rcollyer Adding Protect was a good method of preventing Set instead of just warning the user that it was occurring. Unfortunately, the symbol is still added to the context, so if you unlock and then re-lock all those previously protected symbols are now available. I suppose they could be Removed, instead of just Unprotecting them. Although, that could be made user settable. Also, contextLock can be simplified to
Feb 5, 2017 at 19:54 history edited Kuba CC BY-SA 3.0
added 95 characters in body
Feb 5, 2017 at 19:48 comment added Kuba @rcollyer updated, don't have time to add examples but will do that soon. it is quite selfexplanatory though.
Feb 5, 2017 at 19:47 comment added Kuba @Edmund updated
Feb 5, 2017 at 19:47 history edited Kuba CC BY-SA 3.0
added 252 characters in body
Feb 4, 2017 at 2:43 comment added rcollyer @Kuba to get around the single context, you could use an Association as a set as the keys are guaranteed to be unique, so you can use MemberQ[Keys@assoc, #2] to test if it is a protected context.
Feb 3, 2017 at 14:02 comment added Edmund Okay. The big drawback of your answer is that only once notebook context can be locked at a time. If I call Lock`contextLock[] on notebook A it removes the lock on notebook B. Will have to update my question update to use the repository.
Feb 3, 2017 at 13:43 history edited Kuba CC BY-SA 3.0
added 51 characters in body
Feb 3, 2017 at 6:53 history edited Kuba CC BY-SA 3.0
added 2 characters in body
Feb 3, 2017 at 6:43 history edited Kuba CC BY-SA 3.0
added 215 characters in body
Feb 3, 2017 at 6:29 history answered Kuba CC BY-SA 3.0