ryanc
2019-11-7 14:03:41

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?


jeapostrophe
2019-11-7 14:04:42

I’ll kick it


steveh2009
2019-11-7 14:12:36

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?


soegaard2
2019-11-7 14:13:29

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


steveh2009
2019-11-7 14:20:50

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.


steveh2009
2019-11-7 14:22:16

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


soegaard2
2019-11-7 14:23:17

Is glib used on Windows?


ryanc
2019-11-7 14:25:13

thanks @jeapostrophe!


samth
2019-11-7 14:25:42

@soegaard2 yes


steveh2009
2019-11-7 14:26:29

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


steveh2009
2019-11-7 14:28:58

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


soegaard2
2019-11-7 14:30:34

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


soegaard2
2019-11-7 14:33:03

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


soegaard2
2019-11-7 14:41:16

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


soegaard2
2019-11-7 14:41:46

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


steveh2009
2019-11-7 14:55:31

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.


steveh2009
2019-11-7 14:58:09

It’s a project, for sure.


deactivateduser60718
2019-11-7 19:41:07

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.


samth
2019-11-7 19:41:31

yes, you can do that


samth
2019-11-7 19:42:30

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


samth
2019-11-7 19:42:33

for example


deactivateduser60718
2019-11-7 19:43:24

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


deactivateduser60718
2019-11-7 19:43:28

Thanks muchly.


soegaard2
2019-11-7 19:44:01

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


deactivateduser60718
2019-11-7 19:45:06

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


soegaard2
2019-11-7 19:48:16

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


deactivateduser60718
2019-11-7 19:50:15

Gotcha.


notjack
2019-11-7 22:17:38

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


notjack
2019-11-7 22:19:33

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).


notjack
2019-11-7 22:21:26

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).


notjack
2019-11-8 04:05:12

Fun with transducers, reducers, and multidicts: