README 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. Guile's Emacs Lisp compiler
  2. ===========================
  3. This is more or less a lot of work in progress. Here are some notes as well
  4. as status information.
  5. Already implemented:
  6. * progn, prog1, prog2
  7. * if, cond, when, unless
  8. * not, and, or
  9. * referencing and setting (setq) variables
  10. * set, symbol-value, makunbound, boundp functions
  11. * fset, symbol-function, fmakunbound, fboundp
  12. * funcall, apply (also with raw lists as arguments and the like!)
  13. * eval
  14. * while, dotimes, dolist
  15. * catch, throw, unwind-protect
  16. * let, let*
  17. * lambda expressions, function calls using list notation
  18. * some built-ins (mainly numbers/arithmetic)
  19. * defconst, defvar, defun
  20. * macros
  21. * quotation and backquotation with unquote/unquote-splicing
  22. * specific elisp reader
  23. Especially still missing:
  24. * more general built-ins
  25. * advice?
  26. * defsubst and inlining
  27. * recursive macros
  28. * anonymous macros
  29. Other ideas and things to think about:
  30. * #nil vs. #f/'() handling in Guile
  31. Compiler options implemented:
  32. * #:disable-void-check ['all / '(sym1 sym2 sym3)] to disable the check
  33. for void value on access either completely or for some symbols
  34. * #:always-lexical (usable same as disable-void-check) to always bind
  35. certain or all symbols lexically (including lambda arguments)
  36. Extensions over original elisp:
  37. * guile-ref, guile-primitive
  38. * flet and flet*
  39. * lexical-let and lexical-let*
  40. * without-void-checks, with-always-lexical
  41. Details to the implemented extensions
  42. =====================================
  43. guile-ref and guile-primitive:
  44. ------------------------------
  45. (guile-ref module sym) is a new special construct to access symbols from the
  46. Guile-world. Actually, (guile-ref module sym) is the same as (@ module sym)
  47. would be in Scheme. Both module and sym must be statically given and are not
  48. evaluated.
  49. (guile-primitive sym) does the same to access a Guile primitive directly, which
  50. is slightly faster where applicable.
  51. flet and flet*:
  52. ---------------
  53. These constructs behave exactly like let and let*, except that they bind the
  54. function slots rather than the value slots, and so make dynamic scoping
  55. available for functions, too.
  56. The distinction between flet and flet* is probably less useful than the one
  57. between let and let*, but it was easy to implement both flet and flet*
  58. based on the existing let and let* code, so not having both of them seemed
  59. a little inconsistent.
  60. lexical-let and lexical-let*:
  61. -----------------------------
  62. lexical-let and lexical-let* are constructs provided by the elisp package
  63. 'cl originally, but in Guile they are natively implemented because using
  64. lexical instead of dynamic binding gives better performance in this case.
  65. They work just like let and let*, but bind their target symbols lexically.
  66. Some oberservations with the Emacs 'cl implementation that we mimic in Guile
  67. for compatibility:
  68. * Ordinary let's within the lexical scope of a lexical-let still establish new
  69. *lexical* bindings for symbols already lexically bound. So once lexical,
  70. always lexical (on a per-symbol basis).
  71. * However, lambda constructs within the lexical scope of a lexical-let where
  72. one of their arguments is already lexically bound still bind it dynamically
  73. for their scope.
  74. * On the other hand, symbols lexically bound that are not rebound via the
  75. argument-list build lexical closures just well.
  76. * If symbols are accessed where they are not known at compile-time (like
  77. symbol-value or set primitives), this always refers to the dynamic binding
  78. and never the lexical one. That's very nice to the implementor...
  79. without-void-checks:
  80. --------------------
  81. Disable void checks in addition to the compiler option for all or some symbols
  82. in the lexical scope of this construct:
  83. (without-void-checks all body...) or
  84. (without-void-checks (sym1 sym2 ...) body...
  85. with-always-lexical:
  86. --------------------
  87. As without-void-checks but adds to list of symbols that should always be bound
  88. lexically. This lexical binding includes lambda arguments (if the symbols
  89. match up with the list), which can not be bound lexically otherwise.