Hi,

I started using Emacs about 2 months ago. Now that I am comfortable with customizing Emacs, getting help, and Elisp, I would like to contribute to the project.

 I was looking at the file etc/TODO in the repo, and some items there caught my attention. For example, under 'Important Features'  I found 'Add an "indirect goto" byte-code'. Is this still a desired feature or is it not required due to recent efforts towards native compilation? (In the negative case, please feel free to suggest another item for me to work on)

If it is still desired I would like to work on it and would appreciate guidance. After taking a look at lisp/emacs-lisp/bytecomp.el,it seems that forms such as

 (let ((foo (lambda (x) bar)))
     (dosomething
       (funcall foo toto)
       (blabla (funcall foo titi))))


are compiled by calling byte-compile-let. Before generating the binding for foo, #'(lambda (x) bar) is compiled by calling byte-compile-push-binding-init, which in turn compiles the lambda to bytecode and pushes it to the stack.

So to make it more concrete for my sake, I wrote the following form

(let ((foo (lambda (x) (- x 1))))
  (* (funcall foo 2)
     (- (funcall foo 3) 2)))


and with disassemble inspected the generated bytecode by Emacs 28.1

byte code:
  args: nil
0       constant  <compiled-function>
      args: (x)
    0       varref    x
    1       sub1      
    2       return    

1       dup      
2       varbind   foo
3       constant  2
4       call      1
5       varref    foo
6       constant  3
7       call      1
8       constant  2
9       diff      
10      mult      
11      unbind    1
12      return    


As far as I understood,  the idea of the "indirect goto" here is to eliminate the calls on lines 4 and 7 and replace them with an indirect goto. And as per the TODO entry, the return in line 2 of the compiled lambda would also need to be replaced by a jump back.

So here is where I am a bit lost. Currently, the compiled lambda bytecode lives in the constant vector and a reference(?) to it is pushed into the evaluation stack in line 0 (constant <compiled-function>). Thus, for the indirect goto idea to work, the bytecode of the lambda would need to be part of the bytecode of the let's body**. That way, a computed branch can branch into the lambdas code and it is possible to branch out of it when returning.

Aside from guidance on implementing this, I would appreciate any pointers on how to adequately test it.

Regards,
--
João Paulo L. de Carvalho
Ph.D Computer Science |  IC-UNICAMP | Campinas , SP - Brazil
Postdoctoral Research Fellow | University of Alberta | Edmonton, AB - Canada
joao.carvalho@ic.unicamp.br
joao.carvalho@ualberta.ca

** Forgive me for the lack/miss use of terminology.