Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexknauth/debug
a racket lang-extension for debugging, and a macro for inserting a debug-repl
https://github.com/alexknauth/debug
debug racket
Last synced: about 1 month ago
JSON representation
a racket lang-extension for debugging, and a macro for inserting a debug-repl
- Host: GitHub
- URL: https://github.com/alexknauth/debug
- Owner: AlexKnauth
- License: other
- Created: 2015-10-11T18:39:43.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-05-21T15:55:00.000Z (over 2 years ago)
- Last Synced: 2024-11-18T06:41:02.605Z (about 2 months ago)
- Topics: debug, racket
- Language: Racket
- Homepage:
- Size: 48.8 KB
- Stars: 36
- Watchers: 5
- Forks: 5
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
debug
==
A lang-extension for debugging, based on sugar/debug from [mbutterick/sugar](https://github.com/mbutterick/sugar)documentation: http://pkg-build.racket-lang.org/doc/debug/index.html
### `#lang debug`
To debug the value of an expression, simply put `debug` in front of the language at the top of
the file (for instance `#lang debug racket`), and put `#R`, `#RR` or `#RRR` in front of the
expression.- `#R` reports the value and returns it
- `#RR` reports the value with a line number and returns it
- `#RRR` reports the value with the file and line number, and returns it```racket
#lang debug racket
#R(+ 1 2)
```
Shows the output:
```
(+ 1 2) = 3
3
``````racket
#lang debug racket
(+ 1 2 #R(* 3 4))
```
Shows the output:
```
(* 3 4) = 12
15
```### `#lang debug/no-output`
Allows `#R`, `#RR` and `#RRR` like `#lang debug`, but they don't add any debug output, they just return the expression inside.
### `debug-repl`
```racket
> (require debug/repl)
> (define (f x y)
(debug-repl))
> (f 1 2)
-> ; in the debug-repl now
x
1
-> y
2
-> (+ x y)
3
-> ; exit the debug-repl by pressing ctrl-D
> ; back in the normal repl
(f (λ (g a) (g a)) (list add1 4))
-> ; a new debug-repl
x
#
-> y
(list # 4)
-> (x string->number "3")
3
-> (x (first y) (second y))
5
-> ; exit this debug-repl by pressing ctrl-D
```