
Racket News - Issue 50 https://racket-news.com/2021/05/racket-news-issue-50.html\|https://racket-news.com/2021/05/racket-news-issue-50.html Thanks again @pocmatos

Ah, we have compile-omit-paths
in the sdsl
directory

another silly question: is it (easily) possible to have drracket remove trailing whitespace from source?

Can’t say from the top of my head as I mostly use Emacs. However, I think it’s not possible from vanilla DrRacket (someone might correct me here). I would however look at quickscript for a possible way to implement this feature.

A raco setup
will never install packages. That is, raco pkg install
uses raco setup
, but not the other way around. I guess I’m not clear on how you have sudoku-solver
in some cross-build target without having raco cross ... pkg install
ed it there. (Every cross configuration will have its own package installations.)

@plevexier has joined the channel

There is a key combo to remove extra white space at the current position

Look in the menu- ‘show active keybindings’

Otherwise a ‘remove trailing white space’ could probably could be implemented in quickscript https://docs.racket-lang.org/quickscript/\|https://docs.racket-lang.org/quickscript/

@pocmatos which package are you using for racket on emacs, I tried to set racket-mode, it was a bit, how can I say, degraded compared to DrRacket

compared to say slime, it was a bit disappointing

@plevexier Don’t forget to try racket-xp-mode (part of racket-mode). https://racket-mode.com/ Also Greg has a couple of videos explaining the features of racket-mode: https://www.youtube.com/results?search_query=racket-mode

ah, I may have missed racket-xp-mode

thank you, gonna check

when all is setup correctly, would you say it has all the features from drracket, besides the debugger


though this predates quickscript

Would you mind if I made a quickscript out of that plugin code?

not at all

There is a nice feature that took me a while to discover: If you run the program and the cursor is inside a test submodule, it runs the tests. If the cursor is outside, then the program is run normally.

Thanks. Can I also encourage you to put it on the Racket Package Catalog ? https://pkgs.racket-lang.org/\|https://pkgs.racket-lang.org/

FWIW here is my .emacs with some “DrRacket”-like keybindings for racket-mode: https://gist.github.com/soegaard/942a3074513655292816e0b79c466620

excellent, when I configured it, I only set up a few keybindings, so gonna check what I miss

and you also have great gists and good repos in there :slightly_smiling_face:

:heart:

@plevexier using racket-mode + xp, but I love a minimalistic ide setup - so it’s more than enough for me.

Love DrRacket and use it for the macro expander but I use emacs for everything so using it for racket as well is definitely a plus on my environment.

it is not uncommon for people to use both Racket Mode and DrRacket - switching as required.

right, makes sense, gonna try to configure racket-mode with xp and see how far it brings me, but yeah, I see how using drracket sometimes is necessary

I’ve been spoiled with slime (which is the package for common lisp) I think

For me, DrRacket and racket-mode + racket-xp-mode are somewhat incomparable at the moment. For example, the macro stepper in DrRacket is much better than equivalents in racket-mode. Similarly, other languages that are build as DrRacket tools just don’t exist in racket-mode. And DrRacket separates tabs from each other, which is nice. However, racket-mode is much better for “go to definition”, easier to enable errortrace on demand, and other conveniences.

true @samth

I think neither one is much like slime, because slime is based around a fairly different model of interaction with the underlying system that Racket itself has moved away from.

yes

and for the best really sometimes lol

the image based programming has a lot of sharp edges

#lang racket/base
(require quickscript racket/string)
(define-script whitespace
#:label "Remove trailing whitespace"
(λ (selection)
(let ([linebreak (string #\newline)])
(string-join
(map (λ (line)
(string-trim line #px"\\s+" #:left? #f))
(string-split selection linebreak))
linebreak))))
It doesn’t remove trailing newlines at the end of the file, but otherwise it’s been working for me.

> A raco setup
will never install packages. Ok, that explains the behavior, thanks.
> I guess I’m not clear on how you have sudoku-solver
in some cross-build target without having raco cross ... pkg install
ed it there. I ran raco cross ... exe ...
from the root of my Git working directory. It may actually be that the package wasn’t installed at that time.
For context, so far I only ran raco cross
with the same target as my host environment. Technically, this would of course be rather useless, but it should work and it simplifies testing because I’m able to run the generated binary without copying it to another system. So at this point, for my first experiments, I’m using raco cross
to wrap raco exe
, but I’m not actually cross-compiling.

Hi. Is there any quickscript for structured editing in DrRacket? Something like smartparens or paredit in emacs?

Eventually, I want to use raco cross ... exe ...
to create standalone binaries so that users can download the compiled program without having to install Racket.

It’s not a quickscript but https://pkgs.racket-lang.org/package/drracket-paredit

Thanks! Hmm, that was easy, but I couldn’t find it myself. Looks like the google is broken today

searching on http://pkgs.racket-lang.org\|pkgs.racket-lang.org is useful for this

Nice and simple :slightly_smiling_face: I had also written one for my own needs some time ago, but forgot to publish it—it’s https://gist.github.com/Metaxal/971e7a4d3098ac45930381beb02f8892\|here. This one removes the trailing spaces in the whole current tab, not just in the selection. (Also, https://github.com/racket/racket/wiki/Quickscript-Scripts-for-DrRacket\|wiki updated.)

has become increasingly enamored with DrRacket

In racket/draw/unsafe/cairo.rkt
the identifier _cairo_matrix_t-pointer
isn’t exported. The struct is defined as: (define-cstruct _cairo_matrix_t ([xx _double*]
[yx _double*]
[xy _double*]
[yy _double*]
[x0 _double*]
[y0 _double*])
#:malloc-mode 'atomic-interior)
(provide (struct-out cairo_matrix_t))
So I am thinking, that a hypothetical cstruct-out
also exporting the -pointer
binding would be a good thing. But I have a feeling, I might be overlooking something.
Is there way to get a _cairo_matrix_t-pointer
other than simply duplicating the define-struct
above in my own code?

While it would be better for _cario-matrix_t-pointer
to be exported, I think (define-cpointer-type _cairo_matrix_t-pointer #:tag 'cairo_matrix_t)
is equivalent.

Thanks guys, I am now getting all sorts of ideas what I’d like to do to/with drracket :wink:

Thanks for the tip - works like a charm.

https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/racket-racketbc.html looks like cs now beats bc in the majority of benchmarks! a lot more memory usage though

I think I’d rather that case just throw an exception by default

you can do (-> foo? foo? ... bar?)
to require 1 or more foo?
arguments

I think you can do this without macros

oh yup I see that’s what you did, nevermind me :p

When using a snapshot package catalog, is there a good way to tell what commits were used for Git-based packages? What about release catalogs and https://pkg-build.racket-lang.org/server/built/catalog/?

No, I don’t think that’s recorded anywhere.

hi, can someone explain this behavior to me? ~
λ racket
Welcome to Racket v8.1.0.5 [cs].
> (require plot/pict)
> (define whatever (hash plot-pen-color-map 'set1))
> (parameter-procedure=? plot-pen-color-map (first (hash-keys whatever)))
#t
>
~ took 28s
λ cat whatever.rkt
File: whatever.rkt
1 #lang racket
2 (require plot/pict)
3 (provide whatever)
4
5 (define whatever (hash plot-pen-color-map 'set1))
~
λ racket
Welcome to Racket v8.1.0.5 [cs].
> (require "whatever.rkt" plot/pict)
> (parameter-procedure=? plot-pen-color-map (first (hash-keys whatever)))
#f
seems unpredictable, but I might be wrong about some fundamental assumption

this also happens if I just (define whatever plot-pen-color-map)

cc @samth — could this have something to do with Typed Racket’s exported contracts or parameter guards?

What is plot/pict
? Whenever I require
it, whether from the REPL or DrRacket, the program crashes
$ racket
Welcome to Racket v8.1.0.6 [cs].
> (require plot/pict)
fish: Job 1, 'racket' terminated by signal SIGKILL (Forced quit)

update: https://gist.github.com/ralsei/a5cbaad4c649bcf82c4fa1abbb2ce35d
looks like this is behavior that’s unique to typed-untyped interaction, maybe?