[ prog / sol / mona ]

prog


Why don't lisps have list destructuring automatically in let

1 2018-11-04 02:48

I defined this in my Scheme and it kinda works, but for some reason the macroexpansions changes variable names, which is weird

(define-syntax let+
  (syntax-rules ()
    ((let+ (((pattern ...) list) bindings ...)
       body body+ ...)
     (reverse-args apply list
       (lambda* (pattern ...)
         (let+ (bindings ...)
	       body body+ ...))))

    ((let+ (((pattern pattern+ ... . tail) improper-list)
            bindings ...)
       body body+ ...)
     (let ((pattern (car improper-list)))
       (let+ (((pattern+ ... . tail) (cdr improper-list))
              bindings ...)
         body body+ ...)))

    ((let+ ((let-stuff ...) bindings ...)
       body body+ ...)
     (let ((let-stuff ...))
       (let+ (bindings ...)
         body body+ ...)))

    ((let+ () body body+ ...)
     (begin body body+ ...))))
21


VIP:

do not edit these