locate and code for functions involving options, caching, or @@ are useless
Nobody has claimed this yet.
- Dominant language
- Macaulay2
- Stars
- 435
- Forks
- 297
- Avg merge
- 4d 20h
- Merged PRs (30d)
- 11
Description
Say I want to see where net Variety is defined, so I use locate:
i5 : locate(net, Variety)
o5 = (../../Macaulay2/m2/classes.m2, 90, 47, 90, 54, 90, 50)
But that doesn't make sense, so instead I look up its code:
i8 : code(net, Variety)
o8 = -- code for method: net(Variety)
../../Macaulay2/m2/classes.m2:90:48-90:55: --source code:
Function @@ Function := Function => (f,g) -> x -> f g x
| symbol class value location of symbol
| ------ ----- ----- ------------------
| f : MethodFunctionSingle -- net ../../Macaulay2/m2/classes.m2:90:38-90:39
| g : MethodFunctionSingle -- expression ../../Macaulay2/m2/classes.m2:90:40-90:41
| -- function f:
| function net: source code not available
| -- function g:
| function expression: source code not available
But this is useless: nowhere in this output does it say that net Variety is defined on line 24 of varieties.m2, or even what net and expression do or even where they are defined -- it just says the are also in classes.m2! Even the most useful part of this output, which says that net Variety is the composition of net and expression, is written in too much generality and would be much easier to understand if it just said something like x -> net expression x.
To a smaller extent, the same is true for functions involving options:
i17 : locate(codim, ProjectiveVariety)
o17 = (../../Macaulay2/m2/option.m2, 15, 19, 17, 33, 17, 7)
o17 : Sequence
i18 : code(codim, ProjectiveVariety)
o18 = -- code for method: codim(ProjectiveVariety)
../../Macaulay2/m2/option.m2:15:20-19:34: --source code:
(opts,f) -> args -> (
-- Common code for functions created with >> to process options and arguments.
uncurry(f, override (opts,args))
)
)
| symbol class value location of symbol
| ------ ----- ----- ------------------
| f : FunctionClosure -- ... ../../Macaulay2/m2/option.m2:15:9-15:10
| opts : OptionTable -- OptionTable{Generic => false} ../../Macaulay2/m2/option.m2:15:4-15:8
| -- function f:
| ../../Macaulay2/m2/varieties.m2:299:66-299:87: --source code:
| codim ProjectiveVariety := options(codim,PolynomialRing) >> opts -> X -> codim(ring X,opts)
| -- option table opts:
| OptionTable{Generic => false}
and those involving caching:
i36 : locate(poincare,MonomialIdeal)
o36 = (../../Macaulay2/m2/methods.m2, 654, 51, 663, 25, 655, 56)
o36 : Sequence
i37 : code(poincare, MonomialIdeal)
o37 = -- code for method: poincare(MonomialIdeal)
../../Macaulay2/m2/methods.m2:654:52-663:26: --source code:
cacheValue = key -> f -> new CacheFunction from (x -> (
c := try x.cache else x.cache = new CacheTable;
if c#?key then (
val := c#key;
if class val === CacheFunction then (
remove(c,key);
c#key = val x)
else val
)
else c#key = f x))
| symbol class value location of symbol
| ------ ----- ----- ------------------
| f : FunctionClosure -- ... ../../Macaulay2/m2/methods.m2:654:21-654:22
| key : Symbol -- poincare ../../Macaulay2/m2/methods.m2:654:14-654:17
| -- function f:
| ../../Macaulay2/m2/monideal.m2:98:59-98:123: --source code:
| poincare MonomialIdeal := (cacheValue symbol poincare) (M -> new degreesRing M from rawHilbert rawMonomialIdealToMatrix M.RawMonomialIdeal)
Together, this makes the output of code methods annoyingly long.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the locate and code examples for net(Variety), codim(ProjectiveVariety), and `poincare(MonomialIdeal). Review the referenced locations in m2/classes.m2, m2/option.m2, m2/methods.m2, m2/varieties.m2, and m2/monideal.m2. Done means these commands provide useful defining locations and readable composed-function output without the current excessive detail.
Written by the indexing model from the issue text.
Assessment
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100