laurent.orseau
2021-3-10 09:21:49

I want to write a my-define that basically does the same thing as define but does some more things at compile time, in particular in application position. That works, except that the following code probably doesn’t cooperate well with various other things. For example, the name of the procedure is wrong, but I suspect more things are wrong. What’s the correct way to do it?


laurent.orseau
2021-3-10 09:22:25

So, setting the syntax property 'inferred-name works for this (thanks @yfangzhe). Are there other things I should do to cooperate well with other parts of Racket?


yfangzhe
2021-3-10 09:27:32

Changing line 6 to (define proc (procedure-rename (lambda (arg ...) body ...) 'name))) would help?


laurent.orseau
2021-3-10 09:31:03

Awesome, that works, thanks! Beyond this, I’m wondering if there are other things that need to be fixed in my code



laurent.orseau
2021-3-10 09:38:13

Thanks. Looks like I should set the 'inferred-name syntax property instead then


soegaard2
2021-3-10 11:39:21

I can’t remember either - does the debug setting also affect the number of times?

Maybe the code is expanded before the debugging code is added?


samth
2021-3-10 15:17:46

That’s definitely true — errortrace runs in the eval handler and expands, transforms, and then (necessarily) has to re-expand


laurent.orseau
2021-3-10 16:58:20

Unix: I’m telling the user to run something like racket -l rwind/configure which copies some files in various directories. But it may fail because of permissions, in which case I tell the user to run the sudo racket -l rwind/configure to copy the remaining files. The problem is that if the package is installed in user scope, this will fail with unknown package. Does anyone know a workaround, apart from reinstalling in ‘installation’ scope?


laurent.orseau
2021-3-10 17:01:54

One thing I could do is make a system call with sudo inside the rwind/configure script, but that would be pretty bad style, since the user cannot be certain that there’s no keylogger installed when typing the password


laurent.orseau
2021-3-10 17:04:52

Maybe one thing I can do is tell the user to: cd <rwind-dir> sudo racket configure.rkt


sorawee
2021-3-10 17:10:38

Here’s a crazy idea:

sudo racket $(racket -l rwind/configure) where racket -l rwind/configure outputs /path/to/rwind/configure-main.


laurent.orseau
2021-3-10 17:12:34

Interesting idea. This may be a little simpler though: You probably have to run this command with 'sudo'. Try: sudo racket /home/.../rwind/configure.rkt


laurent.orseau
2021-3-10 19:47:32

Your idea is pretty cool actually and may be refined a little: the first part can configure all that is needed until sudo rights are needed, in which case it returns its own path for sudo and then it can do the rest of the work. That would avoid telling the user to run things twice


laurent.orseau
2021-3-10 19:49:49

The problem is the first part still needs to print things and interact with the user, so some modification is necessary. I’d like to avoid requesting sudo rights if not necessary either, but then we may end up with the original issue of making a script that does sudo, which is unsafe


laurent.orseau
2021-3-10 19:52:40

Even better, the $() could return also the path to racket in case it’s only in the user’s path and not in su’s path


sschwarzer
2021-3-10 22:03:11

Is there a way to load a module from the racket REPL and have access to the identifiers in this module even if they aren’t provided? $ racket > (... "task.rkt") ; what to use? > some-identifier-in-task.rkt


sschwarzer
2021-3-10 22:03:28

I tried require and load.



samdphillips
2021-3-10 22:08:15

oh also at the repl there is ,enter modname


sschwarzer
2021-3-10 22:10:05

Another question: I’m experimenting with macros. I want (group-format (string-append "(" title ")") "Unset title") to be converted to (list (lambda (title) (string-append "(" title ")") "Unset title") My current (seemingly working) macro implementation is (define-syntax (group-format stx) (define title-body-and-unset-title (cdr (syntax->list stx))) (datum->syntax stx `(list (lambda (title) ,(car title-body-and-unset-title)) ,(car (cdr title-body-and-unset-title))))) Is there a cleaner way to write this macro?


sschwarzer
2021-3-10 22:13:48

For the record, if someone else wants to use this, require/expose is defined in rackunit.


sschwarzer
2021-3-10 22:14:00

,enter module is nice. :slightly_smiling_face:


samdphillips
2021-3-10 22:21:40

#lang racket/base (require (for-syntax racket/base) syntax/parse/define) (define-syntax-parse-rule (group-format e0 e1) #:with title (datum->syntax #'e0 'title) (list (lambda (title) e0) e1)) (group-format (string-append "(" title ")") "Unset title")


sschwarzer
2021-3-10 22:22:45

Wow, thanks.


samdphillips
2021-3-10 22:23:04

I’m guessing that you want title to be special inside the first expression


samdphillips
2021-3-10 22:23:45

There may be a nicer (syntax-wise) way to do it with syntax-parameters but to just get things working …


sschwarzer
2021-3-10 22:23:51

I want it to be “special” in the sense that it’s the lambda argument.


sschwarzer
2021-3-10 22:24:25

My macro seems to work, I was only wondering if there were better ways to write it.


sschwarzer
2021-3-10 22:26:30

This is my very first macro. :laughing:


notjack
2021-3-11 01:04:11

I wish there was a way to tell the expander and compiler to skip certain submodules, so that I could compile and run foo.rkt without needing to install any of its dependencies that are only used in test submodules.


sorawee
2021-3-11 02:15:03

@samdphillips I appreciate the use of define-syntax-parse-rule :wink:


samdphillips
2021-3-11 02:19:13

Thanks to whoever added the good deprecation documentation to the old form which I almost used :slightly_smiling_face:


bkwok_77
2021-3-11 03:40:47

@bkwok_77 has joined the channel


samth
2021-3-11 03:45:33

We’ve talked about how it would be nice to automatically split modules like that but it’s hard to do it before compile time.