
installing Drracket on a new Macbook fails. I have just installed macTex so brew seems to be working: Jimmys-MacBook-Pro:~ jsnielsen$ brew cask install racket ==> Satisfying dependencies ==> Downloading https://mirror.racket-lang.org/installers/7.2/racket-7.2-x86_64-macosx.dmg
curl: (7) Failed to connect to http://mirror.racket-lang.org\|mirror.racket-lang.org port 443: Operation timed out Error: Download failed on Cask ‘racket’ with message: Download failed: https://mirror.racket-lang.org/installers/7.2/racket-7.2-x86_64-macosx.dmg

operation has timed out several times including yesterday.

@jimmysnielsen It seems the mirror has been having a few issues. Maybe @jbclements or @mflatt can suggest alternatives.

@jimmysnielsen not sure if there’s anything special with that brew
thing but you can always download the dmg
from https://www.cs.utah.edu/plt/installers/7.2/racket-7.2-x86_64-macosx.dmg

which looks like it’s working.

thx @pocmatos I will get it from utah.

@pocmatos thanks. All is well now, just had to add the $PATH manually. did so via the instructions on https://beautifulracket.com/setting-the-mac-os-path.html

Perfect, great to hear. Now, grab an espresso and go Racket! :sunglasses:

Is anyone doing anything with racket and webassembly? I saw 3 projects on github but I don’t think there is much activity.


@jerome.martin.dev Cool, I missed that somehow.

It was just an experiment, but I got a game working with it

I’ve been playing with web assembly text, but clearly that is going to take a long time to produce anything useful.

Well, I just had to make a canvas fill correctly with pixel data, and from there everything went smoothly

Nice

@casmajavi has joined the channel

How would I convert a procedure name to a string for use in string-append
?

@travis.hinkelman object-name
should give you that for procedures (and other values like structs and things made using structs likes ports etc.).

Well it gives you a symbol but you can symbol->string
or use ~a
.

Even anonymous function values from lambda
get names, they’re just not always good names. :slightly_smiling_face: You can procedure-rename
them. e.g. A few months ago I blogged about doing that with thread thunks for better logging output: https://www.greghendershott.com/2018/11/thread-names.html

I am getting this strange error from file-size
, inconsistently, some of the many times I call it in a loop: file-size: contract violation
expected: file?
given: #<path:/pond/quick/AppleStoreBackup/Music/.DS_Store>
I hope the error message could help to track down the problem, because it refers to file?
and there is no such predicate: the contract asks for path-string?
. But so far I haven’t found file?
in the Racket sources. The problem doesn’t seem to be actually getting the file size, because, out of context, this works: philip@avalon:~$ racket
Welcome to Racket v7.2.
> (file-size "/pond/quick/AppleStoreBackup/Music/.DS_Store")
10244
> (file-size (bytes->path #"/pond/quick/AppleStoreBackup/Music/.DS_Store"))
10244
> (bytes->path #"/pond/quick/AppleStoreBackup/Music/.DS_Store")
#<path:/pond/quick/AppleStoreBackup/Music/.DS_Store>
Also, in case it’s relevant, I encountered this on Ubuntu, despite what you might guess from the file name in question.

Not sure if you are using htdp/dir
(https://docs.racket-lang.org/teachpack/dir.html?q=htdp%2Fdir), as its file-size
uses the file
struct provided by this package. Otherwise I could not provide more help.

@philip.mcgrath that’s indeed odd

Are you familiar with the “file-exists?” predicate? I would imagine that the intent of this contract violation is to signal that the file fails this predicate. Just a guess, though.

I think that @oldsin’s response (in the slack thread) is a compelling theory of how that error message might be generated, but I have no idea how an entirely different file-size
procedure could get called if it’s really just running in a loop!

@oldsin Nope, I’m just using the file-size
from racket/base
. (Or at least, per @lexi.lambda’s comment, I think I am, and I seem to be on the other iterations of the loop.)

I genuinely looked in the source and can’t find a way it could generate that error message

@jbclements Yes, my guess was that file?
is a mis-typed version of file-exists?
—but, of course, the file does exist, and Racket knows that except in this loop. I wondered if the problem might be a system-level error (like, maybe I’m sizing too many files too quickly or something) that a low-level layer like rktio
is incorrectly assuming to be a file-does-not-exist error: but, as I said, I haven’t found anywhere in the source that would put the string file?
into an error message.

@philip.mcgrath Not sure it matters, but: What is the loop iterating? Items from an in-directory
sequence? Or from directory-list
? Or elsewhere?

How big is the program producing the error message? Can you make a smallish program that reproduces it?

The program is very short; here it is: (struct directory (path-bytes) #:prefab)
(struct file (path-bytes size) #:prefab)
(struct symlink (path-bytes target) #:prefab)
(define roots
'(#"/pond/quick/AppleStoreBackup/Music/"
#"/pond/iTunes/"
#"/pond/aux-storage/2018-02-04-iTunes-pre-purge/"
#"/pond/aux-storage/iTunes-remote/"
#"/pond/aux-storage/Sapientia~/philip/Music/"))
(module+ main
(require racket/cmdline racket/file)
(command-line
#:args (output-file)
(call-with-atomic-output-file output-file
(λ (out tmp)
(for* ([root (in-list roots)]
[pth (in-directory (bytes->path root))])
(define bs (path->bytes pth))
(write
(cond
[(link-exists? pth)
(symlink bs (path->bytes (resolve-path pth)))]
[(directory-exists? pth)
(directory bs)]
[(file-exists? pth)
(file bs (with-handlers ([exn:fail? (λ (e)
(println e)
(println pth)
(raise e))])
(file-size pth)))]
[else
bs])
out))))))
(The with-handlers
is from a previous attempt at debugging, which wasn’t helpful.)

The issue is that I haven’t yet managed to reproduce the error outside of walking these particular directories, which are many hundreds of GB.

do you intend for file-size
to call the field accessor of your struct file
at the top there? that looks like what could be happening

Yes, it seems like that should always fail.

…which DrRacket’s binding arrows would make very clear, I might add. :)

Ugh. Yes, that would be the problem. I don’t know why it seemed to work for some number of iterations into the loop … I guess I must not have been getting to the file-exists?
case as early as I expected. Thanks, all.

Ah. So @oldsin had the right intuition — are we sure what what file-size
is bound to? @lexi.lambda is right, the DrR binding arrows help with that, if you’re using DrR and have background expansion on. Otherwise go-to-definition is another sanity check. (I’m typing this as captain-obvious postmortem notes for my own benefit.)

This reminds me, lately I’ve been experimenting more with capitalizing struct names. At least, I was doing that with some prefab structs used for a light wire format. That might have helped here. But I’m not sure that’s a good argument for or against capitalizing struct names.

I guess it’s really just: Racket lets you redefine everything. Which is awesome and usually isn’t a problem.. but sometimes it is.

@mflatt When you use syntax-binding-set-extent
, what are the module path’s resolved relative to?

(or I guess, does it just produce a syntax object with unresolved module path indexes.)

I think the MPIs should be built on some existing MPI, or they should be non-relative MPIs (i.e., don’t use #f
as the base if the path is relative).

Sure, I just note that you can use the self module path ((module-path-index-join #f #f)
) without any seeming errors.

LIke with:
(syntax-binding-set->syntax
(syntax-binding-set-extend
(syntax-binding-set)
'blue
0
(module-path-index-join #f #f))
'hello)