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 logs,
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.
Ah! My apologies. I’ve added your name to our “preferred names” file, and I
hope not to make this mistake again.
Thank you!
John
> On May 8, 2021, at 13:38, Dexter Lagan wrote:
>
> Hello sir,
>
> Thank you ! My name is actually Dexter Santucci. Apologies for the
> confusion. My email addre
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 require
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 contracted
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)
Problem:
Wow, I really butchered a sentence. Let me try it again.
Old: "That is, there's a compile-time "pass" where Racket is focuses on the
code you write and what they can see"
New: "That is, there's a compile-time "pass" where Racket focuses on replacing
used macros with new code, and that pass has
I'm stretching details a bit, but maybe it would help to think of phases as
"passes." That is, there's a compile-time "pass" where Racket is focuses on the
code you write and what they can see. These passes continue until the Racket
program is fully expanded.
Where things get tricky is remember
Thanks folks!
> On May 9, 2021, at 09:38, Robby Findler wrote:
>
>
> Here's one way to write it in modern Racket:
>
> #lang racket
> (require (for-syntax syntax/parse))
>
> (module+ test (require rackunit))
>
> (define-syntax (my-and stx)
> (syntax-parse stx
> [(_) #'#f]
> [(_ e:
Here's one way to write it in modern Racket:
#lang racket
(require (for-syntax syntax/parse))
(module+ test (require rackunit))
(define-syntax (my-and stx)
(syntax-parse stx
[(_) #'#f]
[(_ e:expr) #'e]
[(_ e1:expr e2:expr ...)
#'(if e1 (my-and e2 ...) #f)]))
(module+ test
(
Hi Tim,
In this case Ryan's method leads to:
https://github.com/racket/racket/blob/master/racket/collects/racket/private/qq-and-or.rkt#L440
But in case you are wondering about the style used in that file:
at the point where "qq-and-or.rkt" is used, none of the usual
syntax tools (such as syntax-
Here are the three most convenient ways I know of to find that information
(which is "$RACKET/collects/racket/private/qq-and-or.rkt" in this specific
case):
If you use DrRacket, then open a file that uses `and`, right-click on an
occurrence of `and`, and choose "Open Defining File" (which changes
Where in the repository are macros like "and" and "or" defined?
I tried searching for "and" and "or" ... but you probably know how that
worked out.
Thanks folks!
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and
Hi,
> We are finding a file (or directory) with name "tarzan" inside all
> directories inside given path upto given depth.
>
> Recursion is needed here, because tarzan-near-top-of-tree? calls
> tarzan-in-directory? and tarzan-in-directory? calls
> tarzan-near-top-of-tree? for each file in give
Another solution: #lang racket (define-syntax (def-both-phases stx) (syntax-case stx () ((_ rest ...) #'(begin (define rest ...) (define-for-syntax rest ...) (def-both-phases (my-function x) (+ x 1)) (define-syntax my-macro (lambda (stx) (datum->syntax stx (my-function (cadr (synta
You can put your function in a module and require it both normally and for syntax.#lang racket (module my-function racket (provide my-function) (define (my-function x) (+ x 1))) (require 'my-function (for-syntax 'my-function)) (define-syntax my-macro (lambda (stx) (datum->syntax stx (my-functio
I am using syntax transformers to define macros in Racket. I want to create
some helper functions to help me manipulate the syntax. However, the
functions I defined outside the syntax transformer are not available inside
the syntax transformer. For example, in the following code
(define (my-fun
I am using syntax transformers to define macros in Racket. I want to create
some helper functions to help me manipulate the syntax. However, the
functions I defined outside the syntax transformer are not available inside
the syntax transformer. For example, in the following code
(define (my-fun
18 matches
Mail list logo