-
Notifications
You must be signed in to change notification settings - Fork 332
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
Update 1wf_01_debugging.md #2897
base: main
Are you sure you want to change the base?
Update 1wf_01_debugging.md #2897
Conversation
In the debugging page, some examples regarding print debugging were added, and a link to the stdlib documentation
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.
Thanks @patrick-nicodemus, this is useful. Here are some suggestions.
Print debugging is assisted by compiler builtins that allow a printed error | ||
message to refer to the program location that the error was raised from. |
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.
Print debugging is assisted by compiler builtins that allow a printed error | |
message to refer to the program location that the error was raised from. | |
Compiler builtins improve debugging messages. The location of the error in the program can be displayed. |
The compiler builtin `__LOC__` is substituted at compile time with the | ||
location it occurs in the program, described as a string | ||
"File %S, line %d, characters %d-%d". | ||
One can also get the file name, line number, start character and | ||
end character directly through the __POS__ builtin: |
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.
The compiler builtin `__LOC__` is substituted at compile time with the | |
location it occurs in the program, described as a string | |
"File %S, line %d, characters %d-%d". | |
One can also get the file name, line number, start character and | |
end character directly through the __POS__ builtin: | |
At compile time, the `__LOC__` builtin is substituted with its location in the program, described as a string `"File %S, line %d, characters %d-%d"`. One can also get the file name, line number, start character and end character directly through the `__POS__` builtin: |
Documentation for all debugging compiler builtins is in the | ||
[standard library documentation](https://ocaml.org/manual/5.2/api/Stdlib.html#1_Debugging). |
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.
Documentation for all debugging compiler builtins is in the | |
[standard library documentation](https://ocaml.org/manual/5.2/api/Stdlib.html#1_Debugging). | |
Compiler builtins are described in the | |
[standard library](https://ocaml.org/manual/5.2/api/Stdlib.html#1_Debugging) documentation. |
| None -> Printf.printf "Invalid message at %s" __LOC__; flush stdout; | ||
raise Invalid_argument |
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.
| None -> Printf.printf "Invalid message at %s" __LOC__; flush stdout; | |
raise Invalid_argument | |
| None -> (Printf.eprintf "Invalid message at %s" __LOC__; raise Invalid_argument) |
In the debugging page, some examples regarding print debugging were added, and a link to the stdlib documentation