
Are there any good use cases for setting a parameter with (<parameter-name> <expr>)
instead of with parameterize
?

Yes. Using parameterize
the parameter is changed temporarily. When called directly, the setting is permanent.
Let’s say you are using a library, that has a setting stored in a parameter - and that you don’t want to use the default setting in your program - then set it directly (e.g. the background color of a web-page, say).

Ah, I see. Thank-you :grinning:

ah i see, not it did work, just the changes didn’t take effect in drracket, i had to make a new instance of racket to test it, which well makes total sense

also about i agree with not returning #f
since you have extract-struct-info


idk this good?

Thanks! I commented on the PR.

im still a newb to this contributing thing… do I ammend? (I suppose that breaks the PR because it makes a new commit) do I just add the commit? i made the change of eliminating the accumulator, but i have no idea what I am looking for in the struct tests

:disappointed:

Just add a commit to your branch (struct-auto-info-fix
) and it will automatically update the PR

oh ok

i made the commit but im honestly hopeless with the test case, idk

Here’s one possible test

i added a test

Ah, nice, sorry I was distracted

no worries

One place where I always do this is setting the parameters from command line flags. Like this: https://github.com/racket/scribble/blob/master/scribble-lib/scribble/run.rkt#L44\|https://github.com/racket/scribble/blob/master/scribble-lib/scribble/run.rkt#L44

I’m curious why people use parameters in command-line
. A simple set!
would suffice, no?

It’s not like they are passing the parameter elsewhere either.

I do this usually in case I want to temporarily override or modify them later in some section of code. I mostly don’t want to do that, but on the occasion I do it makes it more convenient.

Maybe there’s another reason to use them, but that’s mine :)

Funny that you should mention that, I just published a package to do precisely this without parameters but more straightforward ‘globals’. I’ve always found parameters too heavy for my use cases (and sometimes wayyy too slow—and almost always I don’t need to worry about thread safety). https://github.com/Metaxal/global This also lets you reuse the guard and the string conversion for other purposes than command line arguments.
pkgs hasn’t compiled the docs yet, not sure why.

There’s probably a problem with the build server again? CC: @samth

which build server?


It failed with pkg: cannot use empty checksum for Git repostory package source
source: <https://github.com/Metaxal/global.git>

@mflatt runs pkg-build, but what does http://pkgs.racket-lang.org\|pkgs.racket-lang.org say?

It doesn’t say anything: https://pkgs.racket-lang.org/package/global Just didn’t compile it (not sure when the next compilation is schedule though)

There’s something wrong with the package — I get an error when I try to install it

The git link is good though

http://pkgs.racket-lang.org\|pkgs.racket-lang.org is not yet reporting a checksum for the package: laptop% raco pkg catalog-show global
Package name: global
Author: <mailto:laurent.orseau@gmail.com\|laurent.orseau@gmail.com>
Source: <https://github.com/Metaxal/global.git>
Checksum:
Tags: command-line, commandline
Description: Define global variables and automatically generate a command line parser.
Ring: 2

@sorawee could it be that struct-copy is broken? i dont have a clean installation of racket since i fixed the bug in mine (it’s also 7.8) but when i tried to (struct a (a b [c #:auto]))
(struct-copy a (a 1 2) [a #f])
i got an arity error, so i suspect it’s either not taking account of the #:auto
or it relied on some other fact

So just need to be patient then?

Yes, probably another bug

#:auto
is a rarely used feature, so I can see why these bugs are undiscovered for so long.

ah I see haha

IIRC, it’s considered a wrong design decision for struct
to support #:auto
. In the Rhombus project (Racket 2), there’s a proposal to remove it.

so i checked the definition of struct-copy-core
it doesn’t take into account #:auto
at all

huh interesting

honestly im using #:auto
as a way to markup some fields, though i should probably properly make a variant of struct
, instead of trying to hack my way out

well i have my structs implement gen:dict
so i can do this without struct-copy

You might find https://docs.racket-lang.org/struct-plus-plus/index.html helpful for your use case.

darn, bookmarked… ill consider it heavily

yeah i see why is a bad design decision… the only way for a field #:auto
to be usable is that if it is also #:mutable
why isn’t #:auto
implicitly #:mutable
escapes me

mmm… I am inclined not to open an issue for this, since I don’t know if it exists in 7.9 (im on 7.8) [on comments]

-- #(struct:exn:fail:contract "vector-ref: contract violation\n expected: vector?\n given: '((for/or ((c columns)) (equal? k c)) #<path:C:\\path\\to\\my\\project\\struct-model-util.rkt> 81 33 3237 35)" #<continuation-mark-set>)
("condition->exn" . #f)
("do-raise" . #f)
("dynamic-wind" . #f)
("errortrace-stack-item->srcloc" . #(struct:srcloc #<path:.../private/stack-checkpoint.rkt> 168 0 6297 203))
("pick-first-defs" . #(struct:srcloc #<path:.../private/stack-checkpoint.rkt> 331 0 13000 425))
("get-exn-source-locs" . #(struct:srcloc #<path:.../private/stack-checkpoint.rkt> 585 0 23184 391))
(#f . #(struct:srcloc #<path:.../private/arrow-val-first.rkt> 486 18 20735 32))
("error-display-handler/stacktrace" . #(struct:srcloc #<path:.../private/debug.rkt> 362 2 15076 2612))
("debug-error-display-handler" . #(struct:srcloc #<path:.../private/debug.rkt> 341 4 14358 566))
("default-uncaught-exception-handler" . #f)
("loop" . #f)
("call-in-empty-metacontinuation-frame" . #f)
("winder-dummy" . #f)
("make" . #(struct:srcloc #<path:.../simple-queue/struct-model-util.rkt> 75 11 2815 609))
("eval-one-top" . #f)
("call-with-stack-checkpoint" . #(struct:srcloc #<path:.../private/stack-checkpoint.rkt> 82 0 3329 442))
("call-in-empty-metacontinuation-frame" . #f)
("call-with-values" . #f)
(#f . #(struct:srcloc #<path:.../private/rep.rkt> 1209 22 50774 1010))
("call-with-break-parameterization" . #(struct:srcloc #<path:.../private/more-scheme.rkt> 148 2 4909 517))
("call-in-empty-metacontinuation-frame" . #f)
("call-with-values" . #f)
(#f . #(struct:srcloc #<path:.../private/rep.rkt> 1180 9 49153 5062))
(#f . #(struct:srcloc #<path:.../private/rep.rkt> 1493 15 64385 1548))
(#f . #(struct:srcloc #<path:.../common/queue.rkt> 435 6 19067 1056))
("call-in-empty-metacontinuation-frame" . #f)
("call-in-empty-metacontinuation-frame" . #f)
(#f . #(struct:srcloc #<path:.../common/queue.rkt> 486 32 21054 120))
("call-with-break-parameterization" . #(struct:srcloc #<path:.../private/more-scheme.rkt> 148 2 4909 517))
("call-in-empty-metacontinuation-frame" . #f)
("eventspace-handler-thread-proc" . #(struct:srcloc #<path:.../common/queue.rkt> 370 11 16515 690))
("call-in-empty-metacontinuation-frame" . #f)
("call-with-empty-metacontinuation-frame-for-swap" . #f)
exception raised by error display handler: vector-ref: contract violation
expected: vector?
given: '((for/or ((c columns)) (equal? k c)) #<path:C:\path\to\my\project\struct-model-util.rkt> 81 33 3237 35); original exception raised: for: expected a sequence for c, got something else: #f
context...:
loop
dynamic-wind
.../private/stack-checkpoint.rkt:168:0: errortrace-stack-item->srcloc
.../private/stack-checkpoint.rkt:331:0: pick-first-defs
.../private/stack-checkpoint.rkt:585:0: get-exn-source-locs
.../private/arrow-val-first.rkt:486:18
.../private/debug.rkt:362:2: error-display-handler/stacktrace
.../private/debug.rkt:341:4: debug-error-display-handler
default-uncaught-exception-handler
loop
call-in-empty-metacontinuation-frame
winder-dummy
.../simple-queue/struct-model-util.rkt:75:11: make
eval-one-top
.../private/stack-checkpoint.rkt:82:0: call-with-stack-checkpoint
call-in-empty-metacontinuation-frame

Yes, it’s fixed in 7.9

i see

Say that I have (define foo ...)
, is there a way to attach a syntax property to #'foo
so that I can check that property in modules that import foo
?

No.

You could make foo
into a macro that expanded to something with a syntax property, but you can’t do that with define
.

Could I attach the syntax property during export? I don’t need the property within the module.

Again, you could provide
a macro that expands to foo
and the macro could put the syntax property on (this is roughly what contract-out
does, for example).

Oh, ok. Now I understand. Thank-you!

If you want to associate information with a binding that has an existing meaning (like a function or variable definition), it usually makes more sense to use a compile-time identifier table.

Ah, thank-you.

It compiled \o/ Thanks to whomever kicked it

I don’t think anyone kicked anything; just the regular timing of updates

I noticed that there is an internal form, match-define-values/derived
. I think that a public version of that form, as well as equivalents for the other matching forms (e.g. match-let-values/derived
, match-lambda/derived
), would be useful. Are those things that could be added to racket/match
?

They could be added; I’d be happy to take a PR. I think that only match-define-values/derived
is really that useful; the other match forms are very simple wrappers

@samth You’re right, the other forms are much simpler.

Then it can be at least 3 days before the first pass? That seems a little long to me (but that’s okay, it wasn’t time sensitive or anything)

Well, to be fair, I did have to install it on several machines, but I resorted to raco pkg install <https://github.com/....git>
which also allows me to update faster

Okay, so syntax-local-lift-expression
made it trivial. What a piece of magic! Thanks again @rokitna
Here’s a simplified version #lang racket
(provide occ+ stats)
(define loccs '())
(define (loccs-add b)
(set! loccs (cons b loccs)))
(define-syntax (occ+ stx)
(syntax-case stx ()
[(_)
(let ([id (syntax-local-lift-expression #'(let ([bx (box 0)])
(loccs-add bx)
bx))])
(with-syntax ([b id])
#`(set-box! b (+ 1 (unbox b)))))]))
(define (stats)
(map unbox loccs))
;;; Example
(define (do!)
(for ([i 10])
(occ+)))
(for ([i 10])
(occ+))
(do!)
(do!)
(do!)
(stats)
Interestingly, it seems I don’t even have to export loccs-add
to use it from a different module, but I’m not clear why—whereas I can’t replace the call to loccs-add
with an in-place set!

And this doesn’t even need a finalizer at the end of each module!