
That is super-cool

on https://github.com/racket/racket/releases, 8.0 is marked as the latest release. Should be 8.1, right? 8.1 is there, it’s just not marked as the latest (and there are no notes)

IIRC @samth said that the 8.0 release on GitHub was just an experiment. That’s why there’s no 8.1.
I do agree that it’s confusing though.

Yeah, I’m not sure what the right thing to do is. Maybe I should just add the release announcement/add a task to do that every release

I created the release

for 8.1

Maybe I’m thick today … in the GUI, get-selection returns a number, I want the string (from the list of choices in choice%). How?


That was it @soegaard2! Thanks! I forgot to look in the superclass.

A “cheat sheet” at the top or bottom of the gui elements would make it easier to spot methods.
https://docs.racket-lang.org/racket-cheat/index.html?q=cheat

Hello. Can someone help me understand the following code for running on command line? More specific, I am confused by the fact that the parser
procedure is never called but yet the program works. Please advise. #! usr/bin/env racket
#lang racket
;; parameter My-Name is one of:
;; - #false
;; - String
(define my-name (make-parameter #false))
;; command line parser
(define parser
(command-line
#:usage-help
"Have the computer greet you!"
#:once-each
[("-n" "--name") NAME
"Set your name"
(my-name NAME)]
#:args () (void)))
;; get-greeting : My-Name -> String
;; Gets the greeting for the given My-Name
(define (get-greeting mn)
(cond
[(boolean? mn) "Hello, unknown person!"]
[(string? mn) (string-append "Hello, " mn "!")]))
;; prints result to the command line
(printf "~a\n" (get-greeting (my-name)))

parser
is not a procedure, it’s just a value, and the right hand side of the definition is run when you run the program. That means that (my-name NAME)
gets run and sets that parameter.

What makes it work is that command-line
is called.

Ahhh… I get it now! parser
is a definition not a procedure (my mixed up).

hmm…So why is it done this way? Why create the parser
definition? Seems like an extra step.

What is this code from?


I don’t know why he wrote it that way

The command-line form can produce values as well, so such a definition can be useful, but it isn’t in this example

ok..thanks!

For an alternate peek, though with less command-line options to parse, see https://github.com/benknoble/slack-archive-viewer/blob/ff440edd9f59664ef13985acb827af939f9bbce6/unpack.rkt#L108 or https://github.com/benknoble/slack-archive-viewer/blob/ff440edd9f59664ef13985acb827af939f9bbce6/merge-meta.rkt#L249 where I define a run-main
function and then in a submodule main
call command-line
to parse arguments and give them to run-main
. The main
submodule is automatically require
d when you do racket <file>
, if one exists (right?). This works for me with #!
scripts too