Hi Ben,
Since ver 0.9.4, I have been struggling with strange error and messages for macro functions.
These are very simplified funcs for explanations ....
;; this is ok without any troubles.
(define-macro (mmt1 . args)
`(list ',args))
(mmt1 10 20) ;->((10 20))
;; this is it !
;; mmt2 is defined, then, it works well without error !
;; but moving the cursor onto "mmt2" in definition or execution/evaluation S-exp,
;; "error" is shown in message place, and warning?? messages in the shell window, too.
(define-macro (mmt2 . args)
(let ((v1 (gensym)))
`(list ',args)))
(mmt2 10 2 3) ; -> ((10 2 3))
;; warning messages
;cadadr argument, (let ((v1 (gensym))) (#_list-values 'list (#_list-values #_quote args))), is a pair but should be a pair whose cdadr is also a pair
; mmt2
; , line 0, position: 85
;xtmdoc-scheme-macro-handler: (cons 'args ... ; name-sym: mmt2
;xtmdoc-scheme-macro-handler: ((list 'type...
;xtmdoc-documentation-function: (cons 'xtm... ; sym: mmt2
;(caddr (get-closure-code (eval name-sym)))
; ..... and so on .....
;; then evaluating this returns error, but,
;; (#_list-values #_quote args) should be
;; (#_list-values (#_quote args))
;; this causes an error
(cdadr (let ((v1 (gensym))) (#_list-values 'list (#_list-values #_quote args))))
;; this returns NIL without error because fixed
(cdadr (let ((v1 (gensym))) (#_list-values 'list (#_list-values (#_quote args)))))
;; If this mmt2 is expanded like above, it doesn't work !
;; Howerver, mmt2 works without no error !
;; So, what is this warning ????
(macro-expand '(mmt2 10 2 3))
;; returns ok, (list (#_quote (10 2 3)))
(list (#_quote (10 2 3)))
;; -> (10 2 3)
(mmt2 10 2 3)
;; -> ((10 2 3))
;; but the next mmt2-b func has no trouble, no error, no warning when the cursor moves onto it.
;; just shows "scheme macro mmt2-b let" as usual ...
;; I think xtmdoc funcs work has some ......
;;
;; the difference is the place of quasiquote,
;; but comparing with not a few funcs, there is one that has no this strange phenomenon, though
;; it has the quqsiquote start position at not the head of body.
(define-macro (mmt2-b . args)
`(let ((v1 (gensym)))
(list ',args)))
(mmt2-b 10 2 3)
;; your some macro funcs as belows, too .....
;; Moving the cursor on to macro func name atom after we defined it,
;; it shows error and warning messages ...
(define-macro (cosr . __cosr-rest)
(let ((args (cons 'cosr __cosr-rest)))
(if (> (length args) 4)
`(+ ,(caddr args) (* ,(cadddr args) (cos (* TWOPI (+ beat ,(cadr args)) ,(car (cddddr args))))))
`(+ ,(cadr args) (* ,(caddr args) (cos (* TWOPI beat ,(cadddr args))))))))
(define-macro (dotill predicate expression . args)
(let ((max-iterations (if (null? args) 100000000 (car args))))
`(let impsym38479k ((cnt 0))
(let ((value ,expression))
(if ,predicate
value
(if (> cnt ,max-iterations)
(begin (log-info "Dropping out after max-iterations")
'failed)
(impsym38479k (+ cnt 1))))))))
(define-macro (:> tag . args)
(let ((tagtime (string->symbol (string-append (symbol->string tag) "_tagtime"))))
(if (not (defined? tagtime)) (eval `(define ,tagtime (now)) (interaction-environment)))
(if (< (eval tagtime) (- (now) (* 2 *second*)))
(eval `(define ,tag #f) (interaction-environment)))
(if (and (defined? tag) (closure? (eval tag)))
`(rmap-loop-runner ,tag ,tagtime modify ,@args)
`(rmap-loop-runner ,tag ,tagtime start ,@args))))
;; of course there are not a few others that show this phenomenon, too
;; What's going on ????
;; xtmdoc funcs can't work well since s7 ?????
;; xtmdoc funcs are in .../extempore-aarch64-v0.10.0/runtime/xtc-bind.xtm
(define mm1
(lambda (x1 x2) x1))
(mm1 10 20)
(xtmdoc-builtin-handler 'mm1) ;error
(xtmdoc-builtin-handler "mm1") ;error
(xtmdoc-builtin-handler mm1) ;error
(xtmdoc-closure-handler mm1) ;error
(xtmdoc-scheme-function-handler 'mm1)
;; -> ((category . "scheme closure") (name . "mm1") (args x1 x2) (type) (docstring))
(xtmdoc-documentation-function "mm1")
;; -> scheme closure mm1 (x1 x2)
;; usually displayed one, when moving the cursor onto "mm1" in definition or S-exp like
(mm1 1 2)
(xtmdoc-scheme-function-handler 'mmt2)
;; -> ((category . "scheme closure") (name . "mmt2") (args . #f) (type) (docstring))
;; oh this is it!
(xtmdoc-documentation-function "mmt2")
;; -> error
;cadadr argument, (let ((v1 (gensym))) (#_list-values 'list (#_list-values #_quote args))), is a pair but should be a pair whose cdadr is also a pair
; mmt2
; , line 0, position: 38
;; xtmdoc-scheme-macro-handler: (cons 'args ... ; name-sym: mmt2
;; xtmdoc-scheme-macro-handler: ((list 'type...
;; xtmdoc-documentation-function: (cons 'xtm... ; sym: mmt2