Thanks for the feedback! Some of these were not concerns for my use case, so 
I’ll do a bit more design before submitting something.

-- 
Sent from my phoneamajig

> On Oct 30, 2020, at 12:36, George Neuner <[email protected]> wrote:
> 
> 
>> On 10/30/2020 3:08 PM, William J. Bowman wrote:
>> Let me aid this discussion by copying in the ~10 lintes of code in question:
>> 
>> > (define-syntax (dictof syn)
>> >   (syntax-parse syn
>> >     [(_ (k:id pred?) ...)
>> >      (quasisyntax/loc syn
>> >        (dictof/proc `((k . ,pred?) ...)))]))
>> > > (define ((dictof/proc spec) h)
>> >   (and (eq? (dict-keys h) (dict-keys spec))
>> >        (for/and ([(k pred?) (in-dict spec)])
>> >          (pred? (dict-ref h k)))))
>> 
>> The macro is merely a syntactic transformation to 1 line of code that 
>> implements
>> the functionality of the contract at run-time.
>> Is there some reason to avoid macros in this particular case?
> 
> There's rarely any problem with macros that only provide syntactic sugar.
> 
> The issues wrt contracts are how heavy are the dictionary functions.  The FOR 
> loop is concerning because the check time is proportional to the size of the 
> dictionary  [again recalling that contracts live on in release code].
> 
> For performance it would be better to enforce the predicate on values as they 
> are entered, and then assume anything already in the dictionary is correct.  
> It is sensible to provide a function that validates the whole dictionary, but 
> I would make it something the programmer has to invoke deliberately rather 
> than a contract to be enforced at (even just 1st in module) mention of the 
> dictionary.
> 
> YMMV,
> George
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/95997336-33d4-5c5b-b329-9ea691fe59ef%40comcast.net.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/E9A25DEF-7B1B-426C-AFAD-319C5C2E9757%40williamjbowman.com.

Reply via email to