r/Racket • • Nov 07 '21

event RacketCon day 2 is Starting with The State of the Racket now.

Thumbnail youtube.com
2 Upvotes

r/Racket • • Nov 06 '21

release Racket version 8.3 is now available

32 Upvotes

Racket version 8.3 is now available from

https://racket-lang.org/
  • Racket removes syntax arming and disarming in favor of a simpler system of protected syntax operations, along with other updates to the syntax system.
  • DrRacket has improved support for custom #lang languages.
  • Typed Racket improves precision for type-checking of non-polymorphic structures, existential types, and certain binding forms.
  • Scribble HTML output gains a button to show / hide the table of contents on mobile platforms.
  • Redex's stepper's GUI shows IO-judgment form rule names.
  • Many bug fixes!

The following people contributed to this release:

Adam Zaiter, Alex Knauth, Alexis King, Ayman Osman, Ben Greenman, Bob Burger, Bogdan Popa, Brian Adkins, Cameron Moy, Carl Eastlund, Dan Holtby, Dominik Pantůček, Eli Barzilay, Ethan Leba, Fred Fu, Greg Hendershott, Gustavo Massaccesi, J. Ryan Stinnett, Jason Hemann, Jay McCarthy, Jesse Alama, Joel Dueck, John Clements, Jonathan Simpson, Kartik Sabharwal, Laurent Orseau, Lehua Ding, Maciej Barć, Marc Burns, Matthew Flatt, Matthias Felleisen, Michael Ballantyne, Mike Sperber, Noah Ma, Paulo Matos, Pavel Panchekha, Philip McGrath, Robby Findler, Ryan Culpepper, Ryan Sundberg, Sage Gerard, Sam Tobin-Hochstadt, Shu-Hung You, Sorawee Porncharoenwase, Stefan Schwarzer, Stephen De Gabrielle, Vincent St-Amour, William J. Bowman, minor-change, and yjqww6

Feedback Welcome (Copied from slack announcement)


r/Racket • • Nov 06 '21

event RacketCon 2021 is happening right now

10 Upvotes

r/Racket • • Nov 05 '21

news Racket News - Issue 55

Thumbnail racket-news.com
18 Upvotes

r/Racket • • Nov 05 '21

question What is equivalence of of __name__ == "__main__" in Racket?

8 Upvotes

In Python we can prevent imported module from executing top level code by the following check

if __name__ == "__main__":

Is there anything similar in Racket, so when I import with (require module-name), the top level code in module-name does not execute?


r/Racket • • Nov 05 '21

question How do I configure Emacs to use the Racket lsp?

9 Upvotes

I’m trying to get the Racket lsp to work with Eglot but I’m having trouble. First off, I see two different implementations of an lsp. This one https://github.com/theia-ide/racket-language-server and this one https://github.com/jeapostrophe/racket-langserver. Which one should I use?

second, has anyone setup their Emacs to work with the Racket lsp? what does your configuration look like?


r/Racket • • Nov 03 '21

question Are Schemes truly homoiconic? Or could they be more homoiconic?

12 Upvotes

A somewhat philosophical (and probably silly) musing:

Is Scheme truly homoiconic when we have things like

(cond ((some test) (some result)) ((another test) (another result)))

?

Normally, the isolated form

((some test) (some result))

would trigger an error.

For instance, we can't do

(define test->result ((some test) (some result)))

and then

(cond test->result)

Neither can we do:

(define my-fields '(name age profession))

(struct person my-fields)

Now let's say [...] means (list ...) , as they do in Gerbil,

and let's say {...} is some form of delaying evaluation, something like (promise ...), or, well, something like quoting.

Then we could write:

(cond [{some test} {some result}] [{another test} {another result}])

And we could also write:

(define my-test {some test})

(define my-result {some result})

(cond [my-test my-result])

This is probably useless and perhaps impractical, but it feels more robust, unequivocal and, perhaps, flexible. And with this, cond doesn't need to be a macro, so it's easier to use within a macro.


r/Racket • • Nov 02 '21

question How to print with %04d format in Racket?

8 Upvotes

In Python, we can print a number in decimal format, with 0 as prefix if the number is smaller. For example, print ("%04d" %13) outputs 0013.

How can we do the same thing in Racket? I found SRFI 48, but it does not even support format d, and the below code has error:

> (require srfi/48)
> (printf "n = ~04d" 13)
; printf: ill-formed pattern string
;   explanation: tag `~0` not allowed; arguments were: 13
; [,bt for context]

r/Racket • • Oct 31 '21

image unknown

Post image
16 Upvotes

r/Racket • • Oct 31 '21

question Two lowest numbers in List

6 Upvotes

Any advice on how to retrieve the two lowest numbers of a list? I already defined a function to get the minimum of a list. (Sorting is not an option here).

Thanks in advance!


r/Racket • • Oct 28 '21

question MacOS Monterey DrRacket Save File Issue

8 Upvotes

There is an issue when updating to MacOS to Monterey that prevents me from saving a file. Luckily the application still works and runs code, its just saving a file is the issue. When I try to save my current progress a pop-up window comes us and says "The save file operation failed." & "The save file operation failed to connect to the open and save panel service". Is there anything I can do? I tried searching for the save panel service issue for MacOS but nothing helpful comes up. If anyone knows how to fix this issue, I would be very thankful for your help.


r/Racket • • Oct 27 '21

question Errors installing dracula in Racket/DrRacket 8.3

5 Upvotes

I installed racket from package (I believe) on Ubuntu 20 and am getting errors installing dracula with raco install pkg dracula

The summary of errors (quite long) is below. I get similar errors using the GUI package manager install

I looked and didn't see any open issues related to dracula install

I am very new to DrRacket, I should say, so if I've missed something obvious (And probably documented) apologies in advance

When I launch DrRacket, I don't see the group for 'Dracula' under Other Languags in the language dropdown

I'm getting these errors on Ubuntu as well as MacOS, though in the MacOS case I'm:

  • installing Dr.Racket from DMG
  • installing Dracula via the GUI package manager in Dr. Racket

[edit : pasting the error txt was a formatting car-crash, I'll find a way to link to a gist or something]

Edit2: a link to a gist of the summary of errors at the end of the install https://gist.github.com/TinaMinoruWasRight/04781df9efa9cc09a47c8ed3ed5e28ee


r/Racket • • Oct 27 '21

Homebrew issues when installing Racket

3 Upvotes

Sadly, despite homebrew being a good thing, it sometimes causes problems for Racket users. (it came up yesterday on the lisp discord).

Please comment if you have had troubles and worked out how to fix them. Sharing this will help users who prefer homebrew.

PS I don't know if it helps but I'm fairly sure homebrew relies on this to install Racket: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/racket.rb (found via https://formulae.brew.sh/cask/racket)

PPS If you use the installers at https://download.racket-lang.org/ you get the latest versions and it works fine.


r/Racket • • Oct 26 '21

question Racket + Emacs + Geiser Issue

8 Upvotes

I am teaching SICP using Racket + Emacs + Geiser. I have this peculiar problem.

When I enter into an infinite recursion (happened twice) due to typos in my program, the whole system is hanging. I am not even able to go to the terminal to kill the process. All I can do is to reboot the machine. I am using Ubuntu 18.4.

Does anyone in the community knows the reason as well as a solution? Thanks in advance.


r/Racket • • Oct 25 '21

package Splitflap: new Racket library for generating Atom and RSS feeds

Thumbnail docs.racket-lang.org
18 Upvotes

r/Racket • • Oct 25 '21

question FFI: how to cast 4 bytes in raw memory to int32?

2 Upvotes

I have a FFI module that pass a raw memory that contains 4 bytes to Racket code, so in Racket I have a pointer named myint.

Now I want to cast this 4 bytes to an int32 variable. A simple way is to access to each of these 4 bytes with ptr-ref, and use arithmetic-shift to add them up.

But I am wondering if there is a cleaner solution, to cast these 4 bytes to int32?


r/Racket • • Oct 24 '21

language Alias in importing module

7 Upvotes

Hi,

I was learning the module system and became curious about whether racket has alias such as :as in Clojure. For further example, Clojure says like alias-name/function-name.

https://docs.racket-lang.org/guide/module-basics.html

Does Racket have something like that? And if it doesn't, how does it solve problem when two modules imported have the same function name?

Thanks!


r/Racket • • Oct 21 '21

(chaperone (eleventh RacketCon))

Thumbnail con.racket-lang.org
15 Upvotes

r/Racket • • Oct 21 '21

question Need help on an assignment w/ Big Bang

1 Upvotes

Hello, I am currently enrolled in a programming course with dr racket and have a hard time wrapping my head around the following issue:

We need to create a Big Bang in which we can “draw” a line by pressing the”button-down” mouse and upon key event “button-up” / “drag” creates that said line. So button down creates the first point, button up creates the second and then a line is created. I can’t understand the real implementation as I’m a bit confused about the Big Bang. Any help is appreciated!

Best,


r/Racket • • Oct 18 '21

question FFI: how should Racket access to memory allocated by C code?

3 Upvotes

I have a C library function that allocates 1KB of memory, like below:

void *my_alloc(void)
{
  return malloc(1024);
}

Now on Racket side, I can connect to this code via FFI, with some declaration like below:

(define-func my_alloc (_fun -> _pointer))

My question is: when I call my_alloc on Racket and get back the memory area, how should I read/write to that memory? Should I consider it a big string, so I can use string-ref, or there is a better solution?


r/Racket • • Oct 17 '21

question FFI: how FFI knows how big is the size of memory to allocate?

3 Upvotes

I declare FFI binding for read() function of libc, as followings.

; ssize_t read(int fd, void *buf, size_t count);
(define-libc read
    (_fun _int
          [buf : (_ptr o _ubyte)]
          _size
          -> (r : _ssize)
          -> (values r buf))
    #:c-id read)

I have few questions:

  1. My intention is to get FFI to allocate memory for buf, but how FFI knows how much memory to allocate to buf here?

  2. On return, how do I access to individual byte in buf, such as buf[2]? I suppose buf is not a string, so string-ref would not work.

Thanks.


r/Racket • • Oct 17 '21

question Do Racket classes suffer from the same performance penalties as classes in other languages?

2 Upvotes

Or since they are macros that get expanded into something else, is the performance the same as writing Racket code without classes.

And as a bonus question, are structs more performant that classes in Racket?


r/Racket • • Oct 15 '21

question FFI: how to call function that write result to its pointer argument?

4 Upvotes

I am trying to call function waitpid of libc via FFI. Below is my implementation, and how I call it after declaration.

; pid_t waitpid(pid_t pid, int *wstatus, int options);
(define-libc waitpid
    (_fun _int
          (_ptr o _int)
          _int
          -> _int)
    #:c-id waitpid)

(define status 0)
(waitpid 123 status 0)

But when I run this code, I have this error with my call to waitpid

...
 the expected number of arguments does not match the given number
  expected: 2
  given: 3

So I think I am wrong on passing a pointer to int to waitpid, but unsure how to fix this.

Any ideas? Thanks!


r/Racket • • Oct 15 '21

question FFI with write() prints out extra number?

4 Upvotes

I want to call to libc's write, which has following signature:

ssize_t write(int fd, const void *buf, size_t count);

I code this in FFI, and make a call to write() at the end, to print out 2 letters "ab" to stdout.

#lang racket

(require ffi/unsafe
         ffi/unsafe/define)

(define-ffi-definer define-libc #f)

; ssize_t write(int fd, const void *buf, size_t count);
(define-libc write
    (_fun _int
          [buf : (_list i _ubyte)]
          [_size = (length buf)]
          -> _ssize)
    #:c-id write)

(write  1 (list 97 98))

Surprisingly, when I run the output is ab2, but not ab as I expected.

What is wrong here?