
Using FFI, I need to use a struct full of booleans members. The struct is shown in this page: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPhysicalDeviceFeatures.html\|https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPhysicalDeviceFeatures.html
You can see that struct is huge. I want to initialize the struct with only two members being true and rest being false. Using the make-VkPhysicalDeviceFeatures constructor seems like a bad idea. The other aproach is create the struct using malloc and then assign true the members I want to. However I want to program in a functional way.
What do you think is the best one?


Somewhere you have to know which ones you want to be true; I’d probably go with the large call to make-Vk...

I’m going to break the f button, let’s go

@mflatt At least on Racket 7.8 CS, it seems that, although not documented as allowing it, continuation-mark-set->iterator
accepts the same #f
shorthand to mean (current-continuation-marks)
as does continuation-mark-set-first
— and, it seems to enable the same “shortcut” mentioned in the docs for the latter: At least on micro-benchmarks it can be measureably faster.
Would it be safe to rely on this and use it? And should the docs be updated to say that?

If yes: Let me know if it would help for me to submit a PR — or, if it would actually take you less time to make that kind of change yourself. :slightly_smiling_face: Either OK for me, just please let me know.

It looks like CS accidentally allows #f
and BC doesn’t, and the same for continuation-mark-set->list*
. Probably the right right at this point is to generalize BC and the docs.

I’ll look into it later today.

Thanks! Especially the ->iterator
flavor, since the motivation already is to be potentially faster, it would be nice if it supported #f
to be potentially even faster-er. :slightly_smiling_face:

A question about contracts. If I have a function with two keyword arguments and I need only one to be provided, both may also be provided but then the value has to be equal. I can get the behavior I want using the following, but I have not been able to do it with a contract, it seems like it should be simple, but I’m clearly missing something. (define (transition #:beg beg #:dur [dur #f] #:end [end #f])
(unless (or dur end)
(error "need one of dur end"))
(when (and dur end (not (= end (+ beg dur))))
(error "begin + duration != endpoint"))
(values beg (or end (+ beg dur))))
The contracts I have tried are as follows. (provide (contract-out [transition (->i (#:beg [beg number?])
(#:dur [dur number?]
#:end [end number?])
#:pre (dur end) (or dur end)
any)]))
#:pre
doesn’t trigger if the optional arguments are missing? (provide (contract-out [transition (first-or/c
(->i (#:end [end number?]
#:beg [beg number?]
#:dur [dur number?])
#:pre (beg dur end) (= (+ beg dur) end)
any)
(->i (#:beg [beg number?]
#:dur [dur number?])
any)
(->i (#:beg [beg number?]
#:end [end number?])
any))]))
For this approach I have varied all orders and using both or/c and first-or/c, I know why or/c doesn’t work due to an ambiguous match, but I would expect first-or/c to work (also doesn’t this mean that or/c really should be named xor/c?)
Is there a simple way to do this? Thanks!

In your first contract-out
code sample, I think the #:pre pre-condition does run even when the optional arguments for dur
and end
are missing in a function call. Try printing the values of dur
and end
in the pre-condition code
(the short story is that a call to (transition #:beg 1 #:end 2)
for example would bind the pre-condition’s dur
to a special value named the-unsupplied-arg
. The predicate unsupplied-arg?
returns #t
just for that special value—there’s an example using it in the ->i
docs near the text “If there are optional arguments” https://docs.racket-lang.org/reference/function-contracts.html?q=-%3Ei#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3ei%29%29)

to check that at most one of those arguments is missing, you could use this as the pre-condition instead of (or dur end)
(nand (unsupplied-arg? dur)
(unsupplied-arg? end))

@blachance works like a charm, many thanks! I think what confused me was how the contract interacted with the default values, which is the say, there is no interaction.

~does someone know how to update the sqlite bundled with racket (in windows)? the version it’s shipped with does not have the new shiny cool stuff™, but i don’t want things to break down either so i want to know if it is safe, (my first guess is that you just have to swap the dll)~
nevermind it seems that swapping the dll does not cause any issues

uhh.. so anyone on racket snapshot 8.0(11/19) have an issue with switch tabs? it just wont work ..


the close button is stuck on being highlighted interestingly

I have the same (windows, 8.0.0.1—2021–01–15 bc), luckly the keybindings still work to navigate around.

Send a bug report to @robby . I know the tabs have been improved lately.