Is there anything like common lisp's describe and/or dissassemble?

In common lisp, it is possible to:

(describe '+)

which results in:

+ is the symbol +, lies in #<PACKAGE COMMON-LISP>, is accessible in 14
packages ...
---snip
 #<SYSTEM-FUNCTION +> is a built-in system function.
 Argument list: (&REST SYSTEM::OTHER-ARGS)
 For more information, evaluate (DISASSEMBLE #'+).
---snip

and

 (DISASSEMBLE #'+)

which shows the disassembly of the procedure.

2 Likes

Yes, you can use the disassemble package: disassemble. Also, if you have that package installed, then the raco decompile command will show the disassembly of procedures in the relevant compiled module.

Here's an example of it running:

[samth@huor:~] r
Welcome to Racket v8.3.0.8 [cs].
> (require disassemble)
> (disassemble +)
       0: 4883fd02                       (cmp rbp #x2)
       4: 7569                           (jnz (+ rip #x69)) ; => 6f
       6: 4889f9                         (mov rcx rdi)
       9: 4c09c1                         (or rcx r8)
       c: f6c107                         (test cl #x7)
       f: 750c                           (jnz (+ rip #xc)) ; => 1d
      11: 4c89c5                         (mov rbp r8)
      14: 4801fd                         (add rbp rdi)
      17: 7004                           (jo (+ rip #x4)) ; => 1d
      19: 41ff6500                       (jmp (mem64+ r13 #x0))
      1d: 49836e6801                     (sub (mem64+ r14 #x68) #x1) ; <=
      22: 753f                           (jnz (+ rip #x3f)) ; => 63
      24: 4d894508                       (mov (mem64+ r13 #x8) r8)
      28: 49897d10                       (mov (mem64+ r13 #x10) rdi)
      2c: 4983c518                       (add r13 #x18)
      30: 488d0d20000000                 (lea rcx (mem+ rip #x20)) ; => 57
<many more lines of code snipped>
6 Likes

Additionally, the package whereis (not installed by default, you need to install it manually) can tell you where the binding comes from

> (whereis-binding #'+)
whereis-module: built-in module has no path: '#%runtime
> (whereis-binding #'make-list)
#<path:.../racket/collects/racket/list.rkt>

5 Likes