-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Position/locate/pseudocode revamp #3363
Conversation
weird, builds fine on my comp. |
another issue, inevitably I'll have to fix the output of |
aha, I think I found an old thread:
maybe this should be in the wiki |
It's two steps: ninja M2-tests-ComputationsBook -- generate output files
ctest -R ComputationsBook -- compare against expected output files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@d-torrance and I have talked a bit about commit message and granularity standards for Macaulay2. I think we both prefer more granular commits (the first commit could have been several bite sized ones), for instance because it's easier to figure out what change broke something using git bisect
.
I don't necessarily want you to go back and split the commit, but on the other hand I'd like to push for better commit message standards, especially outside of personal packages:
Position/locate/pseudocode revamp
change compile order
and again
moved pseudocodeClosureClass def down, fixed test
fix test
Could you squash all your commits into one? I think that would be the easiest thing to do for now.
maybe include this in https://github.com/Macaulay2/M2/wiki/Building-M2-from-source-using-CMake |
OK I'll move things around and then force push into a single commit |
@d-torrance I already reviewed the changes here, but it involves the interpreter so probably two reviews would be more appropriate. Feel free to merge if you approve. |
Yes, I definitely plan on reviewing this (and #3382) soon. |
I'm hesitant about the changes to how pseudocode is displayed. While the current lisp-like display can be hard to read, the parentheses are great for delineating each For example, consider the following current behavior: i1 : disassemble pseudocode(() -> if true then for x in {} do while true do try null)
o1 = (function restargs: false numparms: 0 framesize: 0 frameID: 8611 (if (global-fetch 218) then: (for in: (list ) from: (null) to: (null) when: (null) list:
(null) do: (while (global-fetch 218) do: (try (global-fetch 220) (null) (null)))) else: (null))) Versus the proposed behavior: i1 : pseudocode(() -> if true then for x in {} do while true do try null)
o1 = function {restargs false }
{numparms 0 }
{framesize 0 }
{frameID 8894 }
{body if {global-fetch 219 }}
{ {then for {framesize 1 }}}
{ { {frameID 8895 }}}
{ { {in list {} }}}
{ { {from }}}
{ { {to }}}
{ { {when }}}
{ { {list }}}
{ { {do while {global-fetch 219 }}}}
{ { { {do try {global-fetch 221}}}}}
{ { { { {then }}}}}
{ { { { {else }}}}}
{ {else }}
o1 : PseudocodeClosure With the proposed behavior, it's not clear that Also, in an editor like Emacs, we can move our cursor to a closing parenthesis and it will tell us where the corresponding opening parenthesis is with the current behavior. But in the proposed behavior, there are a bunch of curly braces everywhere. Maybe a compromise would be to keep the basic lisp style, but with proper indentation? Maybe something like the following, which is just the current behavior as indented by Emacs in elisp mode: (function restargs: false
numparms: 0
framesize: 0
frameID: 8611
(if (global-fetch 218)
then:
(for in: (list )
from: (null)
to: (null)
when: (null)
list: (null)
do: (while (global-fetch 218)
do: (try (global-fetch 220)
(null)
(null))))
else: (null))) Also, maybe we could define |
Oh I didn't realize this is the display in Emacs. The html display is very different: #3354 (comment) For some reason I thought the new output was of type Descent, or a similar traversable data structure, but if it's not then I agree with Doug that all the braces are counterproductive. I'm wondering maybe the following would be the most useful:
The second item can happen later, but it's very useful for modern editors. |
Yeah the display uses |
also do you want the "null"s displayed? this is something that M2 is not very consistent about across situations and modes... |
also, I object to all the unncessary colons. |
actually, correction, there does seem to be something wrong with the parenthesising. investigating. |
I mean, this is how almost any interpreter works! That's the whole point, and in some languages you can explicitly view this: julia> Meta.show_sexpr(Meta.parse("4 + 4 / 2"))
(:call, :+, 4, (:call, :/, 4, 2)) |
None of these changes have anything to do with how the interpreter works. In any case, I've changed the parentheses which should match more closely the required form. |
I think the parentheses/braces between toString and disassemble are off still. Can you explain why you prefer disassemble to produce a sequence possibly containing lists which possibly contain another i1 : debug Core; load "Macaulay2Doc/demo1.m2"; g 2
../../Macaulay2/packages/Macaulay2Doc/demo1.m2:8:11:(3):[2]: error: division by zero
../../Macaulay2/packages/Macaulay2Doc/demo1.m2:8:11:(3):[2]: --entering debugger (type help to see debugger commands)
../../Macaulay2/packages/Macaulay2Doc/demo1.m2:8:10-8:13: --source code:
b := 1/x;
ii4 : current
oo4 = 2-OP / 1
fetch 0 0
oo4 : PseudocodeClosure
ii5 : toString current
oo5 = (2-OP / 1 (fetch 0 0))
ii6 : disassemble current
oo6 = (2-OP, /, {1, fetch 0 0})
oo6 : Sequence
ii11 : class \ flatten oo6
oo11 = (String, SymbolBody, Pseudocode, Pseudocode)
oo11 : Sequence You said it's for internal use, but I don't understand what changes if everything was nested sequences without any
I know you're not changing how the interpreter works. The point of For that reason, I think |
|
Yes, that's true, but the idea and purpose I have in mind for |
Fine, I can rename |
change net/toString output of Pseudocode add Pseudocode_* toString Pseudocode parenthesis fix restore disassemble
instead of |
I think I actually kind of miss the colons... Previously, open parentheses indicated the start of a new pseudocode object: i1 : disassemble(() -> if true then 5)
o1 = (function restargs: false numparms: 0 framesize: 0 frameID: 8610 (if
(global-fetch 218) then: 5 else: (null))) But now, there are lots more opening parentheses: i1 : disassemble pseudocode(() -> if true then 5)
o1 = (function (restargs false) (numparms 0) (framesize 0) (frameID 10541) (body
(if (global-fetch 219) (then 5) (else null)))) It looks like maybe Here are a couple possible lisp-y alternatives:
|
Also, what's the difference between |
You guys make up your mind which notation you want for |
it used to be that |
Paul, I'm mostly happy with this now, but the PR is making a lot of changes in d (in particular many changes in the first commit), and I'm nervous about finding a bug in the future and the difficulty of figuring out which changes caused the bug. Do you mind if I make a new PR where I take exactly your changes, but break them up into smaller commits? (All commits still keeping you as the author.) This would make bisecting easier. I can also fix the merge conflicts. Doug, I hear your point, but I think we can come back and fix the string printing later. Does that sound okay? |
Dismissing review because no longer requesting changes, but I'm working on splitting the commits (preserving Paul's authorship) for easier bisecting in the future.
One thing i hadn't thought of before: moving pseudocode and disassemble out to code.m2 means that if there was a problem earlier, say in startup.m2, or in any of the files that need to be loaded before code.m2, we can't use pseudocode/disassemble to debug it. I think at least one of them needs to be in the interpreter. |
Oh totally -- I'm just splitting hairs. |
Should i1 : pseudocode(() -> 1/0)
o1 = function restargs false
numparms 0
framesize 0
frameID 11336
body 2-OP / 1
0
o1 : PseudocodeClosure
i2 : pseudocode functionBody(() -> 1/0)
o2 = 2-OP / 1
0
o2 : Pseudocode |
the correspondence between d classes and m2 classes is not particularly consistent. |
Could you resolve the conflicts, @pzinn ? |
I think @mahrud rewrote this PR -- I will check out the "split" version soon. closing. |
before and after. Various hacks that are no longer necessary have been correspondingly removed.
Pseudocode
type has been revamped. It has been split into two (Pseudocode
andPseudocodeClosure
), has been renamed in d for consistency and also to avoid confusion (the old nameCodeClosure
didn't make it clear that the type only existed for debugging purposes, not for execution).disassemble
has been retired: all pseudocode is automatically disassembled and displayed in a more human-friendly way.tempPosition
has been introduced when exporting symbols in a package, so their position is only determined when the symbol is actually used.This PR is the first part of a series involving debugging and error messages. Hopefully it is self-contained.