SetReplace icon indicating copy to clipboard operation
SetReplace copied to clipboard

GeneralUtilities

Open maxitg opened this issue 4 years ago • 1 comments

The problem

The build-in GeneralUtilities package seems to have a lot of useful functionality, and we don't currently use it in SetReplace. If we can be reasonably sure that it's not going to break in the future Wolfram Language version, we should start using it.

  • [x] Add GeneralUtilities dependency.

Examples

Some examples where it can be useful (feel free to add more):

Scope (and ModuleScope)

Scope allows one to have local variables (like Block or Module). However, it detects them automatically (at definition time), so that they don't have to be manually tracked. This will reduce potential mistakes due to the mismatch of lists of Module variables, and will make the code simpler. This will eliminate the need for a linter to do that.

  • [x] Replace all Modules in the WL code with Scope or ModuleScope. (#460)

KeyAddTo (and KeyUnionTo, KeyPrependTo, KeyAppendTo, KeyJoinTo)

KeyAddTo assumes a default value of 0 for non-existing keys, and will also return the new value. It is useful, for example, in deleteFromVertexIndex in setSubstitutionSystem$wl.m, where the Scan function can simply be replaced with

If[KeyAddTo[index, #, -1] === 0, index[#] =. ] 
  • [ ] Add KeyAddTo where relevant.

SetUsage

SetUsage has significantly more features than usageString, see ? SetUsage.

  • [x] Migrate to SetUsage, and get rid of usageString entirely. #532

maxitg avatar Aug 31 '20 04:08 maxitg

  • [x] Update the guidelines in .github/CONTRIBUTING.md to mention Scope and ModuleScope instead of With and Module

taliesinb avatar Oct 11 '20 10:10 taliesinb