
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?

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?

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

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


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

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?

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

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?

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

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

Here’s a crazy idea:
sudo racket $(racket -l rwind/configure)
where racket -l rwind/configure
outputs /path/to/rwind/configure-main
.

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

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

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

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

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 provide
d? $ racket
> (... "task.rkt") ; what to use?
> some-identifier-in-task.rkt

I tried require
and load
.


oh also at the repl there is ,enter modname

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?

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

,enter module
is nice. :slightly_smiling_face:

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

Wow, thanks.

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

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

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

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

This is my very first macro. :laughing:

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.

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

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

@bkwok_77 has joined the channel

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.