kellysmith12.21
2020-12-1 09:04:46

Suppose that I’m making a #lang that reuses some things from Racket but has different syntax. Is there a general approach to ensuring that errors get reported in a way that makes sense in the syntax of the #lang? One concrete example would be imports/exports: if surface syntax like import foo except (bar, baz) is transformed into (require (except-in foo bar baz)), then an erroneous import needs to be explained in terms of the import ... syntax, not (require ...).


soegaard2
2020-12-1 10:10:14

No. You will need to catch the error and rewrite it. Alternatively (not always possible) check what you can first, then call/use the Racket construct. That way you have fewer error types to worry about.


kellysmith12.21
2020-12-1 10:19:45

That works, thanks, @soegaard2.


mbk.racket
2020-12-1 12:51:57

@mbk.racket has joined the channel


wanpeebaw
2020-12-1 15:33:55

@mflatt My current project is a pretty straightforward bf program translator, which converts the Brainfuck program into a racket module and executes it. It took 20 seconds to execute a famous sample program mandelbrot.b.

https://gist.github.com/sleepnova/0277a1a9bf5f6fe104e222d379452688

But a jit-compiler written in C using DynASM took only 3.2 seconds to execute the same program without any optimization.


code
2020-12-1 16:14:17

I have issues copying a struct with an #:auto field. It seems struct-copy is not smart enough to detect this situation and not call the constructor with the auto argument. Example: > (struct fish ([age #:auto #:mutable]) #:auto-value 0) > (struct shark fish (color)) > (struct-copy shark (shark 'blue) [color 'green]) ; shark: arity mismatch; ; the expected number of arguments does not match the given number ; expected: 1 ; given: 2 ; arguments...: ; 0 ; 'green ; Context: ; /usr/share/racket/collects/racket/repl.rkt:11:26


code
2020-12-1 16:14:41

is this a bug or expected behaviour of struct-copy?


soegaard2
2020-12-1 16:14:50

Is this the latest version of Racket?


code
2020-12-1 16:15:08

No, 7.8


soegaard2
2020-12-1 16:15:16

Pretty recent.


soegaard2
2020-12-1 16:15:47

Check the source of struct-copy.


soegaard2
2020-12-1 16:17:31

Hmm. Where is it defined?


soegaard2
2020-12-1 16:23:10

soegaard2
2020-12-1 16:25:45

Does struct-copy work with auto fields for structs with no super structs?


code
2020-12-1 16:29:15

No it does not either. I looked at the source, but are not familiar enough with macros to understand what is going on. Is it even possible to check if a field of a struct is automatic?


soegaard2
2020-12-1 16:31:34

It’s pretty low-level code. The function struct-type-info can return how many auto fields there are: auto-field-cnt: the number of fields defined by the structure type without a counterpart in the constructor procedure (not counting fields created by its ancestor types);


soegaard2
2020-12-1 16:32:39

And since all automatic fields get the same value, that should be enough for struct-copy I think.


code
2020-12-1 16:34:09

I agree, it should be possible to change the behaviour of struct-copy to work in such cases as well. So should I open an issue for this?


soegaard2
2020-12-1 16:34:34

I think that’s a good idea.


mflatt
2020-12-1 16:35:01

The main thing is probably to make the program functional instead of using set!. Also, the generated code is large, so I had to setenv PLT_CS_COMPILE_LIMIT=100000 to convince Racket CS to really compile it; that didn’t help so much with the set! version, though. With the limit raised, here’s a functional version that runs in about 3 seconds instead of about 17 seconds on my machine;


xuxue
2020-12-1 16:43:21

Can redex use same terminals for non-terminals? like I use same dot to represent two different empty contexts. (Γ ::= · ;; empty (Γ ◃ x : τ)) (ψ ::= · ;; empty (ψ ◃ τ)) I guess no, redex-match can’t match it correctly while in define-judgment-form it works well.



soegaard2
2020-12-1 16:46:26

I am comparing this piece of code from struct-copy (define-values (the-struct-info maybe-field-info) (id->struct-info #'info stx)) (define construct (cadr the-struct-info)) (define pred (caddr the-struct-info)) (define accessors (cadddr the-struct-info)) (define parent (list-ref the-struct-info 5)) to the values returned by struct-type-info: name init-field-cnt auto-field-cnt ascessor-proc mutator-proc immutable-k-list super-type skipped? and can’t get the lists to match. For example, counting from 0, the super-type aka parent ought to have the index 6?


wanpeebaw
2020-12-1 16:49:14

I tried the above code with Racket BC v7.9, and it took 38.9 seconds instead of 20.8 seconds or 3 seconds. Quite a big difference.


dvanhorn
2020-12-1 16:52:51

should be fine. Can you give an example of redex-match not doing the right thing?


code
2020-12-1 17:03:08

this would be consistent with the documentation of module racket/struct-info. Not sure what the relationship to.procedure struct-info from base is


xuxue
2020-12-1 17:09:46

Hi, David, I use a scratch buffer to test a little, found it works fine in simple code (so I think the problem lies on mine, sorry for that :)


soegaard2
2020-12-1 17:27:37

It matches the output of make-struct-type. I must be missing something.


popa.bogdanp
2020-12-1 21:11:04

After using raco ctool to embed a Racket module into a C source file, with the --runtime flag passed in, is it possible to change the root path to the runtime files at runtime? I’m trying to embed some Racket code that depends on gregor (which has some runtime support files for tzdata) into an iOS app, but the only way to know where those files end up within the built app is to query some iOS APIs at runtime (CFBundleGetMainBundle and co.). Using relative paths via the --runtime-access flag doesn’t seem to work.


soegaard2
2020-12-1 21:17:37

@popa.bogdanp I was reminded about your app store app recently. How did the experiment turn out? (Btw - It doesn’t show up in the app strore when I search for “Remember” - it helps to add a “Quick”. Is there a way for you to add search terms?)


popa.bogdanp
2020-12-1 21:27:46

None of the Racket bits were a problem for getting past the review process. They requested some small revisions before allowing the app to be published, mostly to do with the UI and the biggest one being that I add a guide on first run. The app has sold 20 units against 780 views and 6.6k impressions so it has a fairly low conversion rate :sweat_smile:, but at least it’s covered the developer license for a couple of years. I’m thinking about porting it to iOS as well (hence the question above) so we’ll see how that goes, too.


popa.bogdanp
2020-12-1 21:28:29

Re. the search terms, it doesn’t look like I have any control over that stuff.


soegaard2
2020-12-1 21:29:53

Thanks for the info. Good to hear Racket wasn’t a problem. Just curious, what’s the difference between a view and an impression?


popa.bogdanp
2020-12-1 21:30:49

I think a view is counted when someone clicks on the app to view its details and impressions are counted whenever it shows up in a list (search results, featured lists, etc.).


soegaard2
2020-12-1 21:31:50

I actually think the conversion rate is okay - but it’s tricky to get the number of views up.


popa.bogdanp
2020-12-1 21:35:33

Yes, if you only take sales reported against views, then it’s not too bad. The website for the app points at both the App Store and Gumroad so that probably has ended up cannibalizing some App Store sales as well, because on Gumroad you pay what you want. On Gumroad there were 124 sales.


soegaard2
2020-12-1 21:39:57

I see. Yes that’s definitely a factor.



popa.bogdanp
2020-12-1 21:40:48

Despite the low number of sales, though, I’m happy with how it turned out. I was the primary audience for this app and I use it all the time :smile:


pawel.to.malpa
2020-12-1 21:52:54

@pawel.to.malpa has joined the channel


jagen315
2020-12-1 22:19:27

@jagen315 has joined the channel


jason.hemann
2020-12-1 23:12:50

@jason.hemann has joined the channel


mflatt
2020-12-1 23:40:21

If I remember how this all works, the paths are meant to be relative to the executable, so they’re found through (find-system-path 'exec-file) and (find-system-path 'orig-dir).


mflatt
2020-12-1 23:40:32

So, you need a way to set those in an embedding application.


jagen315
2020-12-1 23:41:44

good evening, I’m working on a multimethod-like thing. I originally had it adding instances at runtime, but I decided I needed to lift it into phase 1. Now I’m having trouble getting the instances between modules. Any advice?


mflatt
2020-12-1 23:41:46

In BC, there’s scheme_set_exec_cmd and scheme_set_original_dir


mflatt
2020-12-1 23:42:35

In CS, there are fields for those in racket_boot_arguments_t.


wanpeebaw
2020-12-2 00:45:39

Can I have both Racket BC and Racket CS installed and switch back and forth without any problem? Currently I need to run raco setup each time when using different version. Otherwise, the following problems will occur. read-compiled-linklet: virtual-machine mismatch expected: "chez-scheme"


wanpeebaw
2020-12-2 00:50:26

I tried the above code with Racket CS v7.9, and it took 52.8 seconds to complete.


mflatt
2020-12-2 01:55:18

If you build from a Git checkout using make both, then they coexist more peacefully. Racket BC is racketbc, racobc, etc., and it uses a bc subdirectory of compiled.


samth
2020-12-2 02:20:14

It’s hard to know exactly what you are running into, but I recommend the paper “advanced macrology and the implementation of typed scheme” as a place to start


mflatt
2020-12-2 03:09:34

I’m puzzled, because it runs the same for me with v7.9 CS. That’s all in the part wrapped by time, not compilation (which might otherwise be related to the other thread)?


wanpeebaw
2020-12-2 03:19:30

I have both Racket BC and CS v7.9 installed from pre-compiled dmg files. Do they interfere with each other?


mflatt
2020-12-2 03:20:20

Not necessarily, but it depends on how you install packages.


mflatt
2020-12-2 03:21:58

You can avoid package interference for user-scoped by giving one of the installations a different name with raco pkg config -i --set name.


wanpeebaw
2020-12-2 03:22:44

I use raco pkg install normally. But I have to raco setup before switch between the two to avoid virtual-machine mismatch error.


mflatt
2020-12-2 03:23:31

Changing one of the names will help. Probably the installers should come with different names to help avoid that problem, and we’ll consider that for the next release.


jagen315
2020-12-2 03:23:46

thanks! I got it working, I was on the right track. the problem was I was storing the instances inside a gvector in a define-syntax. each module was getting a fresh copy so the mutations weren’t carrying over (I suppose that is why it is called “syntax-local-value”). I had to do it inside a generated begin-for-syntax instead, as in the paper.


wanpeebaw
2020-12-2 03:27:20

One strange thing is that I don’t have to setenv PLT_CS_COMPILE_LIMIT=100000 to convince Racket CS to run it.


mflatt
2020-12-2 03:55:05

It will run, but in a hybrid interpreted—compiled mode. If you’re not setting the environment variable, that would also explain the slowness.


wanpeebaw
2020-12-2 04:07:04

That’s great, now it finished within 4.2 seconds! It would be nice to have some indication of the execution mode.


notjack
2020-12-2 05:22:55

macro of the day: (regexp-define (as bs cs) #rx"(a*)(b*)(c*)" "aabbbbc") ;; matches regexp against string and binds each group to a variable ;; as is bound to "aa" ;; bs is bound to "bbbb" ;; cs is bound to "c"


ryanc
2020-12-2 06:32:48

match has a redex pattern form that works similarly: (match "aabbbbc" [(regexp #rx"(a*)(b*)(c*)" (list _ as bs cs)) ___])


notjack
2020-12-2 06:42:48

hmm, maybe I should add this to racket/match


notjack
2020-12-2 06:43:23

if I require that the regexp is always a constant literal, I can do lots of validation too to get good error messages and enforce that the number of identifiers is consistent with the number of groups