
I think the package server has stopped checking packages for updates. I don’t see any “Last Checked” timestamps after about 10pm yesterday (UTC). @samth @jeapostrophe?

I’ll kick it

Is the draw-win32-i386 package necessary to install separately to get native drawing or is it already the default in a Win install of Racket?

It’s included (unless you get the minimal distribution).

I was searching on coloring buttons (background) and it seems that it’s non-trivial due to the way glib would handle it. Some code popped up from 2012 but far beyond the one-liner it should be.

Interesting though that setting a text entry field to a different color is a one-liner

Is glib used on Windows?

thanks @jeapostrophe!

@soegaard2 yes

Wouldn’t matter, right? Because the Racket drawing API isn’t going to present setting the background color of a button, native or not.

The bigger question: Shouldn’t setting foreground / background colors on all the GUI common controls be trivial?

Maybe. In the past it probably wasn’t supported on all platforms. But it probably is now.

If you are interested in experimenting, here is the implementation of buttons on Windows (now with correct link): https://github.com/racket/gui/blob/master/gui-lib/mred/private/wx/win32/button.rkt

Not that trivial, I don’t see color listed as a button style: https://docs.microsoft.com/da-dk/windows/win32/controls/button-styles?redirectedfrom=MSDN

But maybe I just don’t know where to look.

On duckduckgo, searched for “go how to set background of a button”. Microsoft support (social.msdn…) links basically say one has to use the BS_OWNERDRAW level. So basically that is treating the button like a bitmap, then you can do whatever you want. And that’s what the 2012 Racket user level code sample from Matthias did as a workaround to it not being supported by the underlying GUI interface.

It’s a project, for sure.

Can a syntax transformer replace code with nothing?
Use case: When I generate Racket code, I’d like to keep logging calls or contracts during development but remove them in time-critical variants.

yes, you can do that

(define-syntax (maybe-keep stx) (syntax-parse stx [(_ e) #:when (condition?) #'(begin e)] [_ #'(void)]))

for example

Ah! I tried returning #'(void)
in the REPL but confused myself since (void)
shows nothing in an interaction anyway.

Thanks muchly.

Sometimes #'(begin)
can be used. Depends on the context.

The context being when leaving no code behind would break the surrounding expression?

If the macro is used in a body, the begin
will be “spliced” away.

Gotcha.

@deactivateduser60718 “definition context” v.s. “expression context” is the usual terminology for that, btw

in an expression context, code can’t be replaced with “nothing” because the code represents an expression and expressions have to evaluate to a value eventually. So #'(void)
is used as a simple expression that does nothing, but it still has a result value and (+ 1 (my-macro-that-expands-to-void) 2)
will throw a runtime error instead of expanding to (+ 1 2)
.

In a definition context, #'(begin)
really does mean “nothing”. Definitions don’t need to evaluate to a value so it’s safe for a macro use to expand to multiple definition forms like #'(begin def1 def2 ...)
or to no definitions at all with #'(begin)
.

Fun with transducers, reducers, and multidicts: