Closed mahrud closed 4 years ago
Speaking of Classic.m2
, the code for it is messy and kind of hard to parse. If the point of its main documentation point is to demonstrate its simplicity, it could use a reorganization.
That location is correct, because this code has no function body:
ideal String := Ideal => ideal % listPolyP : nonspaceAnalyzer
Rather, it uses the Parsing package to make a parser.
I like the code in Classic the way it is: it's super simple and not messy at all.
Isn't ideal % listPolyP : nonspaceAnalyzer
a function?
I'm not suggesting changing the code, just putting some extra tabs and new lines maybe, or adding inline comments perhaps.
Isn't
ideal % listPolyP : nonspaceAnalyzer
a function?
No, it's code that creates a function. The location of the function will be the location of the function body in the source code of Parsing.
I'm not suggesting changing the code, just putting some extra tabs and new lines maybe, or adding inline comments perhaps.
I'm super proud of the small size.
No, it's code that creates a function. The location of the function will be the location of the function body in the source code of Parsing.
And my point is that this makes it almost impossible to understand what ideal(String)
does. Can you make sense of this?
i1 : code (ideal, String)
o1 = -- code for method: ideal(String)
../../Macaulay2/packages/Parsing.m2:41:35-51:6: --source code:
Parser : Analyzer := (p0,a0) -> s -> (
p := p0;
a := a0 s;
while null =!= (k := a())
do (
(pos,t) := k;
if t === null then error("unrecognized lexical item at position ", toString pos)
else if null === (p = p t) then error("syntax error at token '",toString t,"', position ",toString pos)
);
if null === (r := p null) then error "parser unfinished, at end of input";
r)
| symbol class value location of symbol
| ------ ----- ----- ------------------
| a0 : Analyzer -- nonspaceAnalyzer ../../Macaulay2/packages/Parsing.m2:41:26-41:28
| p0 : Parser -- ... ../../Macaulay2/packages/Parsing.m2:41:23-41:25
There's no reference whatsoever to Classic.m2
. How would one know the value of p0
and a0
here?
I'm super proud of the small size.
Okay. I'm just making an observation that it's short but nearly incomprehensible.
No, it's code that creates a function. The location of the function will be the location of the function body in the source code of Parsing.
And my point is that this makes it almost impossible to understand what
ideal(String)
does. Can you make sense of this?i1 : code (ideal, String) o1 = -- code for method: ideal(String) ../../Macaulay2/packages/Parsing.m2:41:35-51:6: --source code: Parser : Analyzer := (p0,a0) -> s -> ( p := p0; a := a0 s; while null =!= (k := a()) do ( (pos,t) := k; if t === null then error("unrecognized lexical item at position ", toString pos) else if null === (p = p t) then error("syntax error at token '",toString t,"', position ",toString pos) ); if null === (r := p null) then error "parser unfinished, at end of input"; r) | symbol class value location of symbol | ------ ----- ----- ------------------ | a0 : Analyzer -- nonspaceAnalyzer ../../Macaulay2/packages/Parsing.m2:41:26-41:28 | p0 : Parser -- ... ../../Macaulay2/packages/Parsing.m2:41:23-41:25
There's no reference whatsoever to
Classic.m2
. How would one know the value ofp0
anda0
here?
Okay, that's a good point. I'll fix it.
Fixed in commit 40623278b2c266466fa2b845ab3a642b548e478c
It's also more readable now. Thank you!
ideal(String)
is defined in Classic.m2, but:Strangely, this is not the case for
matrix(String)
, perhaps because that one takes options?