Assume that we have:

(defalias 'my-f (lambda () (message "a")))
(byte-compile 'my-f)
=> #f(compiled-function
      #<bytecode 0x1dc01052127a>)

(setq my-g (byte-compile (lambda () (message "b"))))
=> #f(compiled-function
     #<bytecode 0x1dc010521246>)

Then I can call disassemble later and select my-f, but that's not the same for my-g, although we know that my-g holds #<bytecode 0x1dc010521246>.

Is it possible to disassemble by supplying #<bytecode 0x1dc010521246> directly?

Edit: my-g is just an example, sometimes I inspect from places such as the backtrace, profiler report buffer, etc., only the address is shown:

361  26%                  - documentation
302  21%                   - substitute-command-keys
287  20%                    - #<compiled -0x1c8af252237f110f>
219  15%                     - kill-buffer

1 Answer 1


Did you try it? You can pass any function, with or without a name, to disassemble:

(disassemble my-g)

results in:

byte code:
  args: nil
0       constant  message
1       constant  "b"
2       call      1
3       return    

Edit: Ok, based on your revision to the question, what you’re asking really has nothing to do with disassembly. What you’re actually trying to do is retrieve a value given a printed representation of its address.

There is no way to do that from Elisp, because that address could refer to a memory that has been garbage collected or reused by now, or because you might supply the wrong type information (whether accidentally or on purpose), etc. Furthermore, the value you see might not actually be an address; in some cases it will be a hash of the value instead.

In the specific case of debugging or profiling some code, you should track the compiled function back to where it came from; what variables or arguments it was stored in, etc, until you find out which function it is. Then you’ll be able to disassemble it. In the specific case you mention, you could modify substitute-command-keys to call disassemble on the function for you, if you couldn’t figure out where it came from or if it was simply never stored in a variable you could access.

  • But how do I do the same if only #<bytecode 0x1dc010521246> is known, but the fact that my-g is set to it isn't acknowledged?
    – Daanturo
    Commented May 11, 2022 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.