kellysmith12.21
2020-11-16 09:54:39

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


soegaard2
2020-11-16 09:57:02

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


kellysmith12.21
2020-11-16 10:01:37

Ah, I see. Thank-you :grinning:


cris2000.espinoza677
2020-11-16 12:33:56

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


cris2000.espinoza677
2020-11-16 12:44:48

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


cris2000.espinoza677
2020-11-16 13:13:04

cris2000.espinoza677
2020-11-16 13:13:08

idk this good?


sorawee
2020-11-16 13:34:29

Thanks! I commented on the PR.


cris2000.espinoza677
2020-11-16 13:43:26

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


cris2000.espinoza677
2020-11-16 13:44:53

:disappointed:


sorawee
2020-11-16 14:06:54

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


cris2000.espinoza677
2020-11-16 14:07:27

oh ok


cris2000.espinoza677
2020-11-16 14:11:35

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


sorawee
2020-11-16 14:33:47

Here’s one possible test


cris2000.espinoza677
2020-11-16 14:45:26

i added a test


sorawee
2020-11-16 14:47:01

Ah, nice, sorry I was distracted


cris2000.espinoza677
2020-11-16 14:47:13

no worries


camoy
2020-11-16 15:20:05

sorawee
2020-11-16 15:21:37

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


sorawee
2020-11-16 15:22:07

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


camoy
2020-11-16 15:23:34

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.


camoy
2020-11-16 15:24:39

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


laurent.orseau
2020-11-16 15:36:47

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.


sorawee
2020-11-16 15:53:28

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


samth
2020-11-16 15:54:54

which build server?


sorawee
2020-11-16 15:55:57

laurent.orseau
2020-11-16 15:56:48

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


samth
2020-11-16 15:57:18

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


laurent.orseau
2020-11-16 15:59:00

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)


samth
2020-11-16 16:04:11

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


laurent.orseau
2020-11-16 16:05:28

The git link is good though


mflatt
2020-11-16 16:05:43

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


cris2000.espinoza677
2020-11-16 16:12:58

@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


laurent.orseau
2020-11-16 16:13:35

So just need to be patient then?


sorawee
2020-11-16 16:14:28

Yes, probably another bug


sorawee
2020-11-16 16:17:10

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


cris2000.espinoza677
2020-11-16 16:17:24

ah I see haha


sorawee
2020-11-16 16:17:41

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.


cris2000.espinoza677
2020-11-16 16:18:08

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


cris2000.espinoza677
2020-11-16 16:18:19

huh interesting


cris2000.espinoza677
2020-11-16 16:20:17

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


cris2000.espinoza677
2020-11-16 16:21:35

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


sorawee
2020-11-16 16:24:08

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


cris2000.espinoza677
2020-11-16 16:26:00

darn, bookmarked… ill consider it heavily


cris2000.espinoza677
2020-11-16 16:38:40

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


cris2000.espinoza677
2020-11-16 16:45:26

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]


cris2000.espinoza677
2020-11-16 16:47:17

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


sorawee
2020-11-16 16:49:16

Yes, it’s fixed in 7.9


cris2000.espinoza677
2020-11-16 16:49:26

i see


kellysmith12.21
2020-11-16 17:13:03

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?


samth
2020-11-16 17:18:59

No.


samth
2020-11-16 17:19:20

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


kellysmith12.21
2020-11-16 17:20:22

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


samth
2020-11-16 17:21:13

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


kellysmith12.21
2020-11-16 17:22:12

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


ryanc
2020-11-16 19:22:04

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.


kellysmith12.21
2020-11-16 19:31:47

Ah, thank-you.


laurent.orseau
2020-11-16 19:39:24

It compiled \o/ Thanks to whomever kicked it


samth
2020-11-16 19:40:57

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


kellysmith12.21
2020-11-16 19:43:59

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?


samth
2020-11-16 19:46:42

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


kellysmith12.21
2020-11-16 20:03:41

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


laurent.orseau
2020-11-16 20:42:05

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)


laurent.orseau
2020-11-16 20:43:15

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


laurent.orseau
2020-11-16 20:52:42

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!


laurent.orseau
2020-11-16 20:53:45

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