gknauth
2018-4-2 19:48:22

I saw sfri–19 mentioned earlier, and gregor. I only recently saw gregor. It looks nice. But I have all this other code that uses sfri–19. And then there is racket/date. I’m trying to figure out if gregor is something people really are using more and more, i.e., whether I should consider moving my code to gregor.


lexi.lambda
2018-4-2 19:52:03

I now exclusively use gregor, so there’s one data point. :)


notjack
2018-4-2 20:22:39

I’d say Gregor is considered the preferred choice in racket - but if you have to rewrite old code so you can use Gregor in new code that’s not good


gknauth
2018-4-2 20:46:08

@notjack I don’t know that I have to rewrite old code. I recognize the conflict between racket/date and gregor date, I have a bunch of stuff that uses srfi–19, and I want to keep adding to that code, which makes me wonder if I should tack, jibe or NOP.


plotnus
2018-4-3 02:24:26

Hello everyone, anyone here good with macros/ willing to offer some help and guidance?


plotnus
2018-4-3 02:24:58

& I have gone through some guides, but am stuck on a particular transformation.


lexi.lambda
2018-4-3 02:28:08

@plotnus etiquette suggests just asking your question, and if anyone can/wants to answer, they will.


plotnus
2018-4-3 02:36:54

Given (defbitarray special-bits ( bit-a bit-b bit-c ))

how could we transform from :bits 'bit-a 'bit-b to :bits (special-bits bit-a bit-b) or better yet have it evaluate to :bits 3 for (define-syntax (foo stx) (syntax-case stx () [(_ bit0 bit ...) ???]))


lexi.lambda
2018-4-3 02:43:34

I’m not sure I understand your question. Where is :bits 'bit-a 'bit-b appearing? At the top level of a module? Inside something else?


plotnus
2018-4-3 02:45:44

@lexi.lambda is is a field in a larger structure that will also need some define-syntax.


plotnus
2018-4-3 02:51:40

@lexi.lambda When I go through the major transformation this macro will be called for the :bits field. E.g. where make-list-of-stuff is the high level macro (make-list-of-stuff big-list (name-of-a :bits 'bit-a 'bit-b :some-symbols 'symbol-a 'symbol-b :some-key-value-list-pairs ('key-a 'value-a 'value-b 'value-c) ('key-b 'value-1 'value-2 'value-3 ... ) (name-of-b more-data.... ) etc... )

so this is just one piece of a larger puzzle


lexi.lambda
2018-4-3 02:59:46

@plotnus It’s hard for me to understand what your constraints are without knowing the bigger picture, but maybe this will point you in the appropriate direction: #lang racket (require (for-syntax syntax/parse syntax/parse/class/local-value)) (define-syntax defbitarray (syntax-parser [(_ bits-name:id (bit-name:id ...)) #:with [bit-index ...] (build-list (length (attribute bit-name)) values) #'(begin (define-syntax bit-name 'bit-index) ...)])) (begin-for-syntax (define-splicing-syntax-class bits-option #:attributes [mask] [pattern {~seq #:bits [{~var bit-name (local-value exact-nonnegative-integer?)} ...+]} #:attr mask (apply + (map (λ (x) (expt 2 x)) (attribute bit-name.local-value)))])) (define-syntax some-macro-that-uses-bits-option (syntax-parser [(_ bits:bits-option) #`(quote #,(attribute bits.mask))])) (defbitarray special-bits (bit-a bit-b bit-c)) (some-macro-that-uses-bits-option #:bits [bit-a bit-b]) The program produces 3 as output.


lexi.lambda
2018-4-3 03:00:08

Oh, and you’ll need to install the syntax-classes package for syntax/parse/class/local-value.


plotnus
2018-4-3 03:01:39

@lexi.lambda thank you. I’ll take a look :slightly_smiling_face: