Add DesmosLib module for Desmos-specific functions
Problem
Currently, users who want to use Desmos-native function names in @desmos macro face challenges because some function names get incorrectly parsed as multi-character variables with subscripts.
Example:
@desmos begin
nCr(n, k) # Currently parsed as n_{Cr}(n, k) ✗
end
Users must use Julia-style names instead:
@desmos begin
binomial(n, k) # Works, converts to \operatorname{nCr}(n,k) ✓
end
While this works functionally, it's not intuitive for users familiar with Desmos who want to use Desmos function names directly.
Proposed Solution
Add a DesmosLib submodule that provides:
- Namespace for Desmos-native function names - allows using Desmos function names directly
- Dummy function definitions with documentation for IDE support
- Proper LaTeX conversion when used inside
@desmos macro
Usage Example
using Desmos
using Desmos: DesmosLib # Optional, but for IDE completion
@desmos begin
# Desmos-native names (via DesmosLib)
DesmosLib.nCr(n, k) # → \operatorname{nCr}(n,k)
DesmosLib.nPr(n, r) # → \operatorname{nPr}(n,r)
# Julia-style names (still work)
binomial(n, k) # → \operatorname{nCr}(n,k)
# Distributions with Desmos naming
DesmosLib.normaldist(μ, σ) # → \operatorname{normaldist}(μ,σ)
Normal(μ, σ) # → \operatorname{normaldist}(μ,σ) (also works)
end
Implementation Tasks
Functions to Include
High Priority (more intuitive with Desmos names)
nCr(n, k) - combinations (currently binomial)
nPr(n, r) - permutations (currently no Julia equivalent)
normaldist(μ, σ) - normal distribution (currently Normal)
uniformdist(a, b) - uniform distribution (currently Uniform)
Medium Priority (for completeness)
- Other distribution functions:
tdist, chisqdist, binomialdist, poissondist, geodist
- Visualization functions:
histogram, dotplot, boxplot
Low Priority (already work well with Julia names)
- Statistical functions that map 1:1 with Julia Base
Alternatives Considered
Option 1: Allow nCr without qualification
- Requires complex macro hygiene
- Hard to maintain
- No IDE support
Option 2: Current approach with Julia names only
- Works functionally
- Less intuitive for Desmos users
- Good for Julia users
Chosen: Option 3 (DesmosLib module)
- Clean namespace separation
- IDE support possible
- Explicit and maintainable
- Users can choose:
DesmosLib.nCr (Desmos-style) or binomial (Julia-style)
- Best of both worlds
Notes
- This is a non-breaking addition
- Existing code continues to work
- Users can gradually adopt
DesmosLib for better Desmos compatibility
- Both styles can coexist in the same
@desmos block
Add DesmosLib module for Desmos-specific functions
Problem
Currently, users who want to use Desmos-native function names in
@desmosmacro face challenges because some function names get incorrectly parsed as multi-character variables with subscripts.Example:
Users must use Julia-style names instead:
While this works functionally, it's not intuitive for users familiar with Desmos who want to use Desmos function names directly.
Proposed Solution
Add a
DesmosLibsubmodule that provides:@desmosmacroUsage Example
Implementation Tasks
src/DesmosLib.jlmodule file_latexify_callto handleDesmosLib.functionsyntax (qualified names)latexify_symbols.jlfor qualified namestest/latexify.jlDesmosLibfrom main moduleFunctions to Include
High Priority (more intuitive with Desmos names)
nCr(n, k)- combinations (currentlybinomial)nPr(n, r)- permutations (currently no Julia equivalent)normaldist(μ, σ)- normal distribution (currentlyNormal)uniformdist(a, b)- uniform distribution (currentlyUniform)Medium Priority (for completeness)
tdist,chisqdist,binomialdist,poissondist,geodisthistogram,dotplot,boxplotLow Priority (already work well with Julia names)
Alternatives Considered
Option 1: Allow
nCrwithout qualificationOption 2: Current approach with Julia names only
Chosen: Option 3 (DesmosLib module)
DesmosLib.nCr(Desmos-style) orbinomial(Julia-style)Notes
DesmosLibfor better Desmos compatibility@desmosblock