hasu / emacs-ob-racket

Emacs Org-Mode Babel code block Racket support
https://tero.hasu.is/blog/2011-09-08-on-racket-support-in-emacs-org-mode.html
GNU General Public License v3.0
36 stars 12 forks source link

Make `ob-racket-runtime-typed` rely on `ob-racket-runtime-private`. #11

Closed scolobb closed 5 months ago

scolobb commented 5 months ago

As discussed in https://github.com/hasu/emacs-ob-racket/pull/10, this PR rewrites ob-racket-runtime-typed.rkt to "simply re-export" the relevant symbols from ob-racket-runtime-private.rkt.

Typed Racket cannot import macros from untyped code (and vice versa), meaning that ob-racket-runtime-typed.rkt still has to explicitly reproduce the definitions of ob-racket-begin-print-elisp and ob-racket-begin-print-table. However, the underlying functions datum->elisp and datum->table are directly imported from ob-racket-runtime-private.rkt with the appropriate type signatures.

https://github.com/hasu/emacs-ob-racket/pull/10 mentions that the original version of ob-racket-runtime-typed.rkt had more restrictive type signatures than the untyped code had. This issue is no longer present in the new simplified code for ob-racket-runtime-typed.rkt, which indeed only assigns 2 very general type signatures.

Finally, I do not think that we incur a major performance penalty by introducing additional contract checks on the boundary between ob-racket-runtime-typed and ob-racket-runtime-private, because this boundary should be traversed at most once per evaluation of the code block, and the additional cost is probably very small compared to other costs associated with evaluating a code block.

hasu commented 5 months ago

Great. As short as one could've hoped for. Thank you.