If you're willing to accept a low tech solution, might I suggest this:
$ perl -i.bak -lpe 's/\(foo/\(make-foo/g' *.rkt
Also, I'll self-plug and point you towards this:
#lang racket
(require struct-plus-plus )
(struct++ foo ([a real?]) (#:omit-reflection) #:prefab)
(define checked (foo++ #:a
I hope so! That's what I understood option B to mean.
I could adjust the define-message macro according to the info in Ryan and
Phillip's attachments, but I'm not well-educated on trapping struct operations.
Phillip: Your example and email gives me the impression that when you add a
chaperone,
On Sun, May 09, 2021 at 10:23:34PM +, Sage Gerard wrote:
> I have a project with 57 prefab structure types. I need to construct
> instances using a local contract (module level contracts do not fit my needs
> here). Since I cannot define guards, the solution is easy enough.
>
> (struct foo
Almost forgot, just in case someone asks: I want to avoid checking for
invariant violations when I print. That would entail checking a bunch of values
in accumulated program output, where it would be awkward to do something
non-printing related, let alone raise an error. When I am printing
Of course, if you're okay with a longer email. Before that, thank you both for
volunteering your time to code something out. I enjoyed running into a
`define-module-boundary-contract` in the wild for the first time.
I sometimes print output in a (read)able form because I like analyzing my logs.
Here's another minimally-tested sample implementation. A more robust
solution might try to chaperone the struct type, as well, to protect
reflective access to the constructor—but I wonder if that really makes
sense when you are working with prefab structs. If you can explain more
about your
I'm not clear on what constraints you're working under with respect to
modules, but hopefully you can adapt this to your needs.
One option is to use a combination of `define-module-boundary-contract` (or
`define/contract`) and `define-match-expander` to bind a name that can be
used as a
I have a project with 57 prefab structure types. I need to construct instances
using a local contract (module level contracts do not fit my needs here). Since
I cannot define guards, the solution is easy enough.
(struct foo (num) #:prefab)
(define/contract make-foo (-> real? foo?) foo)
8 matches
Mail list logo