Search Results
6/14/2025, 4:49:50 PM
>>105584224
>lispsisters, i finally awakened and sort of understand macros (not really) but they are cool
>any racketchad could tell me if its good or not? thanks in advance
i don't have racket installed but the if/null part could be rewritten like:
(define-syntax define-and-provide-parameters-with-contracts
(syntax-rules ()
[(_ ([name val guard] ...))
(begin
(define name (make-parameter val #f)) ...
(provide (contract-out [name (->* () (guard) (or/c guard void?))] ...)))]
[(_ ([name val guard . (converter . rest))] ...))
(begin
(define name (make-parameter val converter)) ...
(provide (contract-out [name (->* () (guard) (or/c guard void?))] ...)))]))
in this case (converter . rest) doesn't do anything ([name val guard converter] would do the same thing) but maybe you want to process rest later. if you're curious you can car/cdr recurse on lists in macros just like functions:
(define-syntax m
(syntax-rules ()
[(_ ())
0]
[(_ (a . b))
(+ a (m b))]))
>lispsisters, i finally awakened and sort of understand macros (not really) but they are cool
>any racketchad could tell me if its good or not? thanks in advance
i don't have racket installed but the if/null part could be rewritten like:
(define-syntax define-and-provide-parameters-with-contracts
(syntax-rules ()
[(_ ([name val guard] ...))
(begin
(define name (make-parameter val #f)) ...
(provide (contract-out [name (->* () (guard) (or/c guard void?))] ...)))]
[(_ ([name val guard . (converter . rest))] ...))
(begin
(define name (make-parameter val converter)) ...
(provide (contract-out [name (->* () (guard) (or/c guard void?))] ...)))]))
in this case (converter . rest) doesn't do anything ([name val guard converter] would do the same thing) but maybe you want to process rest later. if you're curious you can car/cdr recurse on lists in macros just like functions:
(define-syntax m
(syntax-rules ()
[(_ ())
0]
[(_ (a . b))
(+ a (m b))]))
Page 1