On Tue, Mar 3, 2020 at 5:16 AM Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:

(define-syntax +
  (lambda (stx)
    (syntax-case stx ()
      ((_ x y) #'(fast-binary-plus x y))
      (_ #'slow-general-plus))))

It should now work in any R6RS system and in any R7RS system that supports this fragment of the `syntax-case' system.

Except that it will now be impossible to use (apply + '(1 2 3 4)), unless you have a non-standard Scheme that allows both syntax and variable bindings for the same identifier.  Being able to apply procedures to a programmatically generated list of arguments is a standard and important part of functional languages.  In addition, it becomes impossible to put + into a data structure.

CL has this feature, named "compiler macros"; they override a function binding in the compiler, but do not affect any use of the function object at run time.  From what I understand, they are not heavily used.



John Cowan          http://vrici.lojban.org/~cowan        xxxxxx@ccil.org
Objective consideration of contemporary phenomena compel the conclusion
that optimum or inadequate performance in the trend of competitive
activities exhibits no tendency to be commensurate with innate capacity,
but that a considerable element of the unpredictable must invariably be
taken into account. --Ecclesiastes 9:11, Orwell/Brown version