anmolagarwal4453
2021-5-31 09:31:07

@anmolagarwal4453 has joined the channel


philip.mcgrath
2021-5-31 10:09:41

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?


raoul.schorer
2021-5-31 10:53:17

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.


philip.mcgrath
2021-5-31 11:00:51

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")))


raoul.schorer
2021-5-31 11:08:35

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:


sschwarzer
2021-5-31 11:38:15

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.


chansey97
2021-5-31 12:20:55

> 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).


raoul.schorer
2021-5-31 12:44:41

Indeed, that’s a good idea


greg
2021-5-31 13:12:11

Sometimes for/or or for/and are a good choice for breaking early.


jesse697
2021-5-31 14:10:41

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
2021-5-31 14:40:36

@michaelbychko has joined the channel


ben.knoble
2021-5-31 15:17:19

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)


philip.mcgrath
2021-5-31 16:01:40

I think multi-in can do this, but it often ends up confusing me.


soegaard2
2021-5-31 16:05:02

@jesse697 Reading the docs on relative-in it seems to be the right construct. Does it work, if you leave out file ?


jesse697
2021-5-31 16:17:12

@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")


soegaard2
2021-5-31 16:20:22

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.


philip.mcgrath
2021-5-31 16:21:50

I think you need more parentheses—seriously, around the sub-paths.


philip.mcgrath
2021-5-31 16:22:54

From the docs: (require (multi-in "utils" ("math.rkt" "matrix.rkt")))


jesse697
2021-5-31 16:23:29

“I think you need more parentheses” <== this lol


jesse697
2021-5-31 16:24:01

ah, multi-in; I missed that, thanks


jesse697
2021-5-31 16:25:58

wait I need racket/require?


jesse697
2021-5-31 16:26:58

that works — thank you! (seems kinda ugly to have to require racket/require, but so it goes


greg
2021-5-31 19:09:44

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.


greg
2021-5-31 19:11:51

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.


philip.mcgrath
2021-5-31 20:00:01

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 requires. 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.


soegaard2
2021-5-31 20:34:41

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?

https://github.com/soegaard/cairo


soegaard2
2021-5-31 20:37:25

@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


mflatt
2021-5-31 20:43:56

If you want cairo-main content to be in the immediate cairo collection, then include (define collection "cairo") in cairo-main/info.rkt.


mflatt
2021-5-31 20:45:15

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.


mflatt
2021-5-31 20:46:23

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?


shu--hung
2021-5-31 20:47:25

btw, how did you install the package? Did you add info.rkt after package installation or edited the collection field?


soegaard2
2021-5-31 20:47:30

I tested in the terminal with: GitHub % raco pkg update cairo/


soegaard2
2021-5-31 20:47:52

Haven’t submitted the package to the package server yet.


soegaard2
2021-5-31 20:50:17

Let’s keep the status quo then.


shu--hung
2021-5-31 20:50:55

Not sure why it was an pkg update command. I cloned the repo and this works: raco pkg install --name cairo-lib ./cairo-lib/


soegaard2
2021-5-31 20:51:47

Can you run the tests too?


mflatt
2021-5-31 20:53:02

I think you want to create a cairo package that implies cairo-lib and cairo-test.


shu--hung
2021-5-31 20:53:05

Yes but not quite: cairo-test/test3.rkt:14:62: bitmap%: unbound identifier in: bitmap%


shu--hung
2021-5-31 20:53:50

and yes I also manually installed cairo-test


soegaard2
2021-5-31 21:01:03

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))


shu--hung
2021-5-31 21:10:18

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


shu--hung
2021-5-31 21:10:53

soegaard2
2021-5-31 21:18:18

Nope - I am still missing something. Installing cairo using the package manager in DrRacket still leads the same problem. (That (require cairo) fails.)


shu--hung
2021-5-31 21:20:13

How about removing all cairo packages and re-install them again?


soegaard2
2021-5-31 21:21:13

I did that indirectly by using a newer version of DrRacket than the one I use in the terminal.


shu--hung
2021-5-31 21:22:26

Not sure why that is relevant. I think the collection information is only inspected at package installation time and will never be checked again.


soegaard2
2021-5-31 21:25:06

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.


soegaard2
2021-5-31 21:26:31

Just in case, I entered something incorrectly:


shu--hung
2021-5-31 21:28:47

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.


soegaard2
2021-5-31 21:29:05

Ah! I think, I am missing a directory. I need cairo-lib/cairo and not simply cairo-lib


shu--hung
2021-5-31 21:29:52

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


shu--hung
2021-5-31 21:30:10

Plus, the collection information isn’t updated unless you remove and re-install the library


soegaard2
2021-5-31 21:30:12

Yeah, it is multi.


shu--hung
2021-5-31 21:31:49

The file on github is still "cairo" and not 'multi — could be why it works for me.


soegaard2
2021-5-31 21:32:19

Wait - which info.rkt are we talking about :wink:


shu--hung
2021-5-31 21:33:33

I’m looking at cairo-lib/info.rkt because that file defines how Rackets looks for cairo/main


soegaard2
2021-5-31 21:34:32

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>)))


soegaard2
2021-5-31 21:35:23

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))


shu--hung
2021-5-31 21:38:05

In this case, the files ./cairo-lib will be placed in the cairo collection


shu--hung
2021-5-31 21:38:47

When I currently clone the repo and run raco pkg install inside &lt;repo&gt;/cairo-lib, I need to use (require cairo/cairo/main) to import the library


shu--hung
2021-5-31 21:39:27

If there are previous package installations and info.rkt just get updated, I suspect the old configuration is interfering with the new info.rkt


soegaard2
2021-5-31 21:39:55

I was trying to mimic the organization of errortrace: https://github.com/racket/errortrace/tree/master/errortrace-lib


shu--hung
2021-5-31 21:40:17

errortrace-lib has collection 'multi in &lt;repo&gt;/errortrace-lib


soegaard2
2021-5-31 21:40:26

Ah!


soegaard2
2021-5-31 21:47:52

Nope. I’ll postpone my experiments till tomorrow.


shu--hung
2021-5-31 22:03:10

shu--hung
2021-5-31 22:04:18

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


shu--hung
2021-5-31 22:06:30

[May 31 17:01:04]$ raco pkg install -j 1 cairo Resolved "cairo" via file://&lt;HOME&gt;/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://&lt;HOME&gt;/universe/cairo/loclogs/ Resolved "cairo-test" via file://&lt;HOME&gt;/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 &lt;pkgs&gt;/cairo-test/tests/cairo cairo-test/tests/cairo/test3.rkt:14:62: bitmap%: unbound identifier in: bitmap% compilation context...: &lt;HOME&gt;/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]. &gt; (require cairo) &gt; ^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...:


shu--hung
2021-5-31 22:06:37

(I setup a local catalog to test things out)


soegaard2
2021-5-31 22:12:16

Thanks! Ignore test3.rkt.