earl
2019-3-13 11:16:31

Hey, my company bought a couple extra diversity tickets for racketfest, if you know anyone who’s in an underrepresented group and would be interested, please have them reach out!


pocmatos
2019-3-13 11:43:03

@earl Awesome. Have you tweetted about it?


earl
2019-3-13 12:03:31

@pocmatos not yet, I have all of ~300 twitter followers so not sure it’s going to move the needle a ton.


pocmatos
2019-3-13 12:04:09

but it will allow others to retweet you. :slightly_smiling_face: Not that I have that many followers myself though.



earl
2019-3-13 12:11:05

If you do follow me, you can get my best take on Amsterdam, Scala, running an Agtech startup in the developing world… and customer service issues and complaining about american politics which is what I really use it for.


earl
2019-3-13 12:12:12

Anyone who’s going to racketfest in berlin interested in doing a long bike ride on Sunday?


n.huu.long
2019-3-13 13:13:47

@n.huu.long has joined the channel


sorawee
2019-3-13 15:07:53

Is there any difference between stx->list and syntax->list? The documentation seems to imply that stx->list uses syntax->list, but it seems to be identical on all inputs I tried so far


samth
2019-3-13 15:09:04

@sorawee stx->list has a much bigger domain: > (stx->list (list 1 2 3)) '(1 2 3) > (syntax->list (list 1 2 3)) ; syntax->list: contract violation ; expected: syntax? ; given: '(1 2 3) ; [,bt for context]


sorawee
2019-3-13 15:09:26

Ah, I see


sorawee
2019-3-13 15:09:34

Thanks


sorawee
2019-3-13 15:11:32

Perhaps the examples at https://docs.racket-lang.org/syntax/syntax-helpers.html#%28def._%28%28lib._syntax%2Fstx..rkt%29._stx-list~3f%29%29 should include a list that doesn’t have any syntax object inside?


alexknauth
2019-3-13 15:16:05

It also includes things that are neither proper lists nor syntax objects, but chains of cons pairs that might have syntax-lists in the rest instead of normal lists: > (stx->list (cons 1 (cons 2 #'(5 3)))) '(1 2 #<syntax 5> #<syntax 3>) > (syntax->list (cons 1 (cons 2 #'(5 3)))) syntax->list: contract violation expected: syntax? given: '(1 2 . #<syntax (5 3)>)


mark.warren
2019-3-13 15:38:15

Does anyone know if there is a package for doing transactions (NOT database transactions)?


samth
2019-3-13 15:47:33

@pocmatos can you change the gitlab notifications to not email me? and even better, to post to the #notifications channel here?


pocmatos
2019-3-13 16:26:50

@samth Sure. I am out today but will do that today as soon as I return.


notjack
2019-3-13 18:58:49

@mark.warren like, transactions in the sense of software transactional memory (STM)?


lexi.lambda
2019-3-13 19:37:07

Good heavens: #lang racket (define (println/c v) (make-contract #:projection (λ (blame) (λ (val) (println v) val)))) (define/contract foo% (class/c (override [m (println/c #f)])) (class object% (super-new) (define/public (m) #f))) (define/contract foo+c1% (class/c (override [m (println/c 1)])) foo%) (define/contract foo+c2% (class/c (override [m (println/c 2)])) foo%) (class foo+c2% (super-new) (define/override (m) #f)) outputs 2 1 #f #<class:/tmp/test.rkt:21:0> :scream:



greg
2019-3-13 19:53:34

Is it bad for me to prefer (for ([_ (in-producer void)]) __) over (let id () _ (id)) or the equivalent (define (id) _ (id)) ?


greg
2019-3-13 19:54:24

Is there some other idiom for “forever” that is too clever for its own good? :grin:


soegaard2
2019-3-13 20:04:17

So you want a for-ever ! :wink:


jaz
2019-3-13 20:04:52

… and corresponding for*/ever


sorawee
2019-3-13 22:15:24

The documentation says that define-struct is deprecated and struct is more preferable. However, there’s only define-struct/contract and no struct/contract. Is define-struct/contract considered deprecated too? And what should we use instead?


sorawee
2019-3-13 22:17:22

(I’m aware of contract-out with struct/c, but that’s not what I want to do)


greg
2019-3-13 22:29:11

@sorawee I’ve wondered the same thing, then just used define-struct/contract, assuming it hadn’t been worth getting around to renaming or aliasing that, yet.


abmclin
2019-3-13 22:30:25

@sorawee If you want to be able to protect your struct inside a module, you could define the struct inside a sub module then provide the struct bindings via contract-out and struct/c so they’re protected and available for use in the parent module.


lexi.lambda
2019-3-13 22:35:42

There’s a thing called struct-guard/c on HEAD that will be in 7.3 that might be interesting to you.


lexi.lambda
2019-3-13 22:36:09

It lets you write this: > (struct snake (weight hungry?) #:guard (struct-guard/c real? boolean?)) > (snake 1.5 "yep") snake, field 2: contract violation expected: boolean? given: "yep" in: boolean? contract from: top-level blaming: top-level (assuming the contract is correct) at: eval:2.0


greg
2019-3-13 22:36:20

I’ve also done (module foo typed/racket/base __) and a TR struct b/c I prefer its syntax ¯_(ツ)_/¯


greg
2019-3-13 22:37:35

I meant that in response to @abmclin, another variation on defining the struct in a submod. I didn’t mean I prefer this to what @lexi.lambda suggested; I’d never heard of that until now. :smile:


lexi.lambda
2019-3-13 22:38:19

It’s very new! It isn’t even in 7.2.


lexi.lambda
2019-3-13 22:38:39

Robby added it about a month ago.


abmclin
2019-3-13 22:38:41

That looks very nice! I’m looking forward to 7.3


robby
2019-3-13 22:39:50

It is in a nightly build I believe.


robby
2019-3-13 22:40:05

Feedback is easier to respond to before it gets into a release. :)


greg
2019-3-13 22:41:22

So comparing things, I’m guessing the #:guard (struct-guard/c __) approach is only checking contracts when updating the struct — not when reading it. (Which if that’s the case, is either a drawback or a huge perf advantage, depending on what you want.) ?


robby
2019-3-13 22:41:54

It guards the constructor. Doesn’t work for mutable struct


robby
2019-3-13 22:41:57

S


abmclin
2019-3-13 22:42:01

Is struct-guard/c only available in racket/contract and racket?


notjack
2019-3-13 22:43:12

If you use immutable structs, struct-guard/c is the safest way to enforce things


greg
2019-3-13 22:43:14

I meant, with define-struct/contract, I thought the contract is applied/checked even when using read accessors. No?


notjack
2019-3-13 22:44:31

@greg I don’t know, but for immutable structs you probably don’t want to check the reads anyway


greg
2019-3-13 22:45:41

That’s why I thought, “Oh, maybe part of the motivation for struct-guard/c was it intentionally only guards the construction, not the read accesses, as contrasted with d-s/c.” Just curious.


notjack
2019-3-13 22:46:43

@greg out of curiosity, what sort of places do you usually find yourself using mutable structs?


greg
2019-3-13 22:47:11

Almost never.


greg
2019-3-13 22:48:09

I don’t like mutability. And when I have to use it, the struct setters are super verbose and it’s usually easier to set! local variables in a closure.


sorawee
2019-3-14 05:08:11

I’m looking forward to using struct-guard/c!


sorawee
2019-3-14 05:11:26

@mflatt what guarantee does Racket give when I mess with current-compile? In particular, my buggy code results in the following error:

hash-ref: no value found for key
  key: 'foo
  context...:
   compile-identifier22
   compile5
   [repeats 1 more time]
   compile-let13
   compile5
   [repeats 4 more times]
   compile-let13
   compile5
   [repeats 5 more times]
   for-loop
   compile-let13
   compile5
   for-loop
   loop!
   compile-forms33
   compile-module-from-parsed34
   ...

Is this considered a Racket bug? Or all bets are off when I mess with the compiler?