@anmolagarwal4453 has joined the channel
Is there a rule that determines which Northwestern snapshots are kept for a relatively long time? Or, more to the point, is there one from the last few days that’s likely to be retained longer than the others?
While iterating over a sequence with for
and related, is there a way to break out of the for
form and return a single arbitrary value (imperative-style), such as #f
? I know of #:break
and #:final
but those return a partial sequence and not a single chosen value.
Sometimes you can make #:break
/#:final
do what you want, but, in general, you can use a continuation: (let/ec return
(for ([i (in-naturals)])
(return #f)
(error "won't get here")))
thanks! Yes indeed, that’s what I’ve been using but I’ll need to translate my code into languages without continuations. I guess I’ll have to rewrite as a named let :cry:
Maybe you can generalize your for
loop to use for/fold
? In that case, you could return anything. A potential problem could be that you need to return a value for each accumulator if you use several (I think), but I guess most loops will use just one accumulator.
> but I’ll need to translate my code into languages without continuations. Maybe you can translate the let/ec
to exception
(assuming the target language supports exception
).
Indeed, that’s a good idea
Sometimes for/or
or for/and
are a good choice for breaking early.
I’m trying to require a bunch of modules in an adjacent directory from the current one — you need to go up one directory, and then down into a different one. I’m trying to use require
with relative-in
, but I think I’m barking up the wrong tree there. I’m basically looking for something like
(require (in-directory "../tests/" (file "foo.rkt") (file "bar.rkt") ...))
The idea is that the presence of my fictional in-directory
would basically just prepend "../tests/" to each of the paths afterwards. Does the relative-in
form work like that, and I’m just misusing it? Or perhaps such functionality is just missing.
@michaelbychko has joined the channel
For the life of me, I cannot find out what relative-in
actually does. With files a/{b,c}.rkt
, I cannot get any variation of (require (relative-in "a" "b.rkt" "c.rkt"))
to work. And I cant get expand-import
to show what’s going on, so I can’t figure out how to “inspect” it. I just get errors about b & c not found in the current directory (not in a)
I think multi-in
can do this, but it often ends up confusing me.
@jesse697 Reading the docs on relative-in
it seems to be the right construct. Does it work, if you leave out file
?
@soegaard2 unfortunately I still get the error: tests/data.rkt:4:22: relative-in: bad module path
at: "../src/"
in: (relative-in "../src/" "types.rkt" "tokenize.rkt" "tokens.rkt")
Wait a minute … A module-path identifies a module, either a root module or a submodule that is declared lexically within another module.
So "../src/" is not a module path.
I think you need more parentheses—seriously, around the sub-paths.
From the docs: (require (multi-in "utils" ("math.rkt" "matrix.rkt")))
“I think you need more parentheses” <== this lol
ah, multi-in; I missed that, thanks
wait I need racket/require
?
that works — thank you! (seems kinda ugly to have to require
racket/require
, but so it goes
Although #lang racket (require racket/require)
may seem redundant, it’s a good hint to the optimizer that, much like cowbell, you want more racket
and more require
.
Seriously it is annoying to need to require that, and, do so before your other requires. That details feels a little un-Rackety? But, it does de-noise the rest of the require, so on balance it’s nice.
I often set up a library or #lang
with a “standard library” for a given project, particularly including <https://docs.racket-lang.org/adjutor/Stable.html#%28form._%28%28lib._adjutor%2Fmain..rkt%29.require-provide%29%29|my >require-provide
<https://docs.racket-lang.org/adjutor/Stable.html#%28form.%28%28lib._adjutor%2Fmain..rkt%29.require-provide%29%29| macro>, so everywhere else I can avoid noise in my require
s. But, while it does have <https://docs.racket-lang.org/adjutor/Stable.html#%28form.%28%28lib._adjutor%2Fmain..rkt%29.require-provide%29%29|a >multi
<https://docs.racket-lang.org/adjutor/Stable.html#%28form.%28%28lib._adjutor%2Fmain..rkt%29._require-provide%29%29| subform>, note that it’s in the unstable section. As I mentioned, I tend to get confused by multi-in
doing IIRC the Cartesian product of its clauses: I’m not sure my implementation is right, and I’m even less convinced that faithfully recreating the semantics of multi-in
is really what I want to do.
Hi All. I need to be reminding of how my info.rkt files need to look like. I have extended the set of Cairo bindings in racket/draw and now want to make a multi package where the implementation is in cairo-lib
and the tests are in cairo-test
.
But … when I use (require cairo)
in the tests, I am told that cairo/main.rkt
is not to be found. It’s supposed to find cairo-lib/main.rkt
, but I need something in info.rkt
to make it work.
What?
@mflatt Would it be better to move the bindings in “bindings.rkt” to racket/draw/unsafe/cairo
?
https://github.com/soegaard/cairo/blob/main/cairo-lib/bindings.rkt
If you want cairo-main
content to be in the immediate cairo
collection, then include (define collection "cairo")
in cairo-main/info.rkt
.
I have no strong opinion. It’s nice for racket/draw
to have only things that it needs, but it’s also nice to have Cairo things together. I lean weakly toward the status quo.
I see that you have that already.
You’re using something like <https://github.com/soegaard/cairo?path=cairo-lib>
as the source for the cairo-lib
package?
btw, how did you install the package? Did you add info.rkt
after package installation or edited the collection
field?
I tested in the terminal with: GitHub % raco pkg update cairo/
Haven’t submitted the package to the package server yet.
Let’s keep the status quo then.
Not sure why it was an pkg update
command. I cloned the repo and this works: raco pkg install --name cairo-lib ./cairo-lib/
Can you run the tests too?
I think you want to create a cairo
package that implies cairo-lib
and cairo-test
.
Yes but not quite: cairo-test/test3.rkt:14:62: bitmap%: unbound identifier
in: bitmap%
and yes I also manually installed cairo-test
I added cairo/info.rkt
: #lang info
(define collection 'multi)
(define deps '("cairo-lib" "cairo-test"))
(define implies '("cairo-lib" "cairo-test"))
(define pkg-desc "Bindings for the 2d graphics library Cairo mathing the C api.")
(define pkg-authors '(soegaard))
btw, the common case I see is that the pointer package implies the -lib
library and the -doc
library, while the -test
library is not installed automatically
Nope - I am still missing something. Installing cairo using the package manager in DrRacket still leads the same problem. (That (require cairo)
fails.)
How about removing all cairo packages and re-install them again?
I did that indirectly by using a newer version of DrRacket than the one I use in the terminal.
Not sure why that is relevant. I think the collection information is only inspected at package installation time and will never be checked again.
I am not following. Cairo wasn’t installed for the version of DrRacket that I used to test (from the package server). In the terminal (using an older version), I used pkg update
which removes the old package first, then installs again.
Just in case, I entered something incorrectly:
Okay, I didn’t know you are going through the package server. My point is that I doubt whether raco pkg update
in the top-level directory would’ve worked, because it is now there different libraries in cairo/cairo
, cairo/cairo-lib
and cairo/cairo-test
.
I don’t know what package raco pkg update
removed and the package it installs. Installing in the top-level directory is different from installing in the three subdirectories.
Ah! I think, I am missing a directory. I need cairo-lib/cairo and not simply cairo-lib
If the collection is "cairo"
, then there’s no need for the extra library. If the collection is 'multi
, then you need a directory cairo-lib/cairo
Plus, the collection information isn’t updated unless you remove and re-install the library
Yeah, it is multi.
The file on github is still "cairo"
and not 'multi
— could be why it works for me.
Wait - which info.rkt are we talking about :wink:
I’m looking at cairo-lib/info.rkt
because that file defines how Rackets looks for cairo/main
Okay, that’s currently: #lang info
(define collection "cairo")
(define deps '("base"))
(define build-deps '())
(define pkg-desc "Bindings for the 2d graphics library Cairo mathing the C api.")
(define pkg-authors '(soegaard))
(define version "1.0")
(define test-responsibles '((all <mailto:jensaxel@soegaard.net\|jensaxel@soegaard.net>)))
The one in cairo/info.rkt is: #lang info
(define collection 'multi)
(define deps '("cairo-lib" "cairo-test"))
(define implies '("cairo-lib" "cairo-test"))
(define pkg-desc "Bindings for the 2d graphics library Cairo mathing the C api.")
(define pkg-authors '(soegaard))
In this case, the files ./cairo-lib
will be placed in the cairo
collection
When I currently clone the repo and run raco pkg install
inside <repo>/cairo-lib
, I need to use (require cairo/cairo/main)
to import the library
If there are previous package installations and info.rkt
just get updated, I suspect the old configuration is interfering with the new info.rkt
I was trying to mimic the organization of errortrace: https://github.com/racket/errortrace/tree/master/errortrace-lib
errortrace-lib
has collection 'multi
in <repo>/errortrace-lib
Ah!
Nope. I’ll postpone my experiments till tomorrow.
And I think you need to register multiple entries on the package server, each pointing to the right subdirectory on GitHub like what errortrace
does
[May 31 17:01:04]$ raco pkg install -j 1 cairo
Resolved "cairo" via file://<HOME>/universe/cairo/loclogs/
The following uninstalled packages are listed as dependencies of cairo:
cairo-lib
cairo-test
Would you like to install these dependencies? [Y/n/a/c/?]
00: Resolved "cairo-lib" via file://<HOME>/universe/cairo/loclogs/
Resolved "cairo-test" via file://<HOME>/universe/cairo/loclogs/
The following uninstalled packages were listed as dependencies
and they were installed:
dependencies of cairo:
cairo-lib
cairo-test
...
raco setup: in <pkgs>/cairo-test/tests/cairo
cairo-test/tests/cairo/test3.rkt:14:62: bitmap%: unbound identifier
in: bitmap%
compilation context...:
<HOME>/universe/cairo/cairo-test/tests/cairo/test3.rkt
location...:
cairo-test/tests/cairo/test3.rkt:14:62
context...:
withenv:~/universe/cairo
[May 31 17:01:41]$ racket
Welcome to Racket v8.0.0.10 [cs].
> (require cairo)
> ^D
withenv:~/universe/cairo
[May 31 17:01:48]$ racket -l- tests/cairo/test
'(1 16 0)
"1.16.0"
......
(object:bitmap% ...)
ImageSurface: expected either a bitmap or both width and height with an optional format
context...:
(I setup a local catalog to test things out)
Thanks! Ignore test3.rkt.