Can be used with eq?
maybe?
Another possible use is to make it a some
variant
Although I prefer using a new gensym as a none
variant more.
There aren’t any uses for immutable boxes, in my experience
They exist mostly because boxes are in the syntax, and syntax needs to be immutable.
do
in Racket is something different; it’s an iteration construct inherited from Scheme. Once you understand the idea of store-passing, you’ll notice similar situations. If you want to take care of the boilerplate, you can write a Racket macro. Mutable variables and parameters also help. When I said “do-notation”, I meant for monads in statically typed languages, not Racket. You don’t need to understand this idea any time soon, but when you run across it, you might make the mental connection with store-passing.
This was a surprise! I wonder how long multi-line strings have been a thing. I thought for sure I tried them before discovering #<<EOF
, but maybe not.
When writing grammars in defform
and related forms, how can I include a literal ...
?
That is, a reference to syntax binding ...
and not just printed ellipses.
I don’t think the #:literals
clause would be correct, because I do also want to use the printed ellipses in some parts of the grammar.
@(define lit-ellipsis (racket ...))
Then use #,lit-ellipsis
in the grammar section.
See how it’s used in syntax-case
@sorawee Thanks!
i’m reading about contracts, i’m a bit confused. https://docs.racket-lang.org/reference/data-structure-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%29%29\|any and https://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29\|any/c any allows to feed a function any lists of arguments while any/c supplies a single argument to a function. am i correct ?
No, any
is only valid for the returning values from a function.
For example:
(lambda (x) x)
satisfies(-> any/c any/c)
(lambda (x) x)
satisfies(-> any/c any)
(lambda (x) (values x x))
satisfies(-> any/c any)
(lambda (x) (values x x))
does not satisfy(-> any/c any/c)
And (-> any any/c)
is not valid syntactically.
(-> any/c any/c)
do you mean input values and returning values like in type signatures?
Yeah
ok
thanks,