epony has quit [Ping timeout: 252 seconds]
iyzsong has joined #racket
ziyourenxiang has joined #racket
slemonide has joined #racket
slemonide has quit [Client Quit]
wingsorc has quit [Ping timeout: 268 seconds]
dented42 has joined #racket
epony has joined #racket
Arcaelyx has joined #racket
pera has quit [Ping timeout: 245 seconds]
hyperreal has joined #racket
hannes4 has quit [Ping timeout: 264 seconds]
Fernando-Basso has quit [Remote host closed the connection]
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
badkins has quit [Remote host closed the connection]
cryptokey has joined #racket
<cryptokey> Does anybody know if there's a function to check for at least one occurrence of an element in a list?
<cryptokey> not return that occurrence or its index, but just check if it exists?
<bremner> rudybot: (list? (member 'a '(b a d)))
<rudybot> bremner: ; Value: #t
<bremner> rudybot: (list? (member 'a '(b c d)))
<rudybot> bremner: ; Value: #f
<bremner> cryptokey: ^
<bremner> cryptokey: the student languages seem to have member? functions, but for #lang racket you'll have to make your own.
<bremner> for things like 'if' and 'cond', you can just use member, of course
pera has joined #racket
<bremner> (or maybe not "of course", depending how familiar you are with how booleans work in racket)
epony has quit [Ping timeout: 252 seconds]
pera has quit [Ping timeout: 268 seconds]
epony has joined #racket
hyperreal has left #racket ["WeeChat 1.9.1"]
<cryptokey> Thank you!
jao has quit [Ping timeout: 272 seconds]
<greghendershott> I tend to write `(and (member _ __) #t)`
endobson has joined #racket
libertyprime has joined #racket
epony has quit [Ping timeout: 268 seconds]
epony has joined #racket
epony has quit [Excess Flood]
epony has joined #racket
epony has quit [Excess Flood]
_whitelogger has joined #racket
rnmhdn has joined #racket
epony has joined #racket
epony has quit [Max SendQ exceeded]
orivej has quit [Ping timeout: 252 seconds]
epony has joined #racket
pierpal has joined #racket
pierpal has quit [Quit: Poof]
pierpal has joined #racket
selimcan has quit [Ping timeout: 268 seconds]
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #racket
dddddd has quit [Remote host closed the connection]
_whitelogger has joined #racket
rnmhdn has quit [Ping timeout: 244 seconds]
ZombieChicken has quit [Ping timeout: 256 seconds]
rnmhdn has joined #racket
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #racket
pierpal has quit [Ping timeout: 252 seconds]
pierpal has joined #racket
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #racket
rnmhdn has quit [Ping timeout: 272 seconds]
g00s has joined #racket
ziyourenxiang has quit [Ping timeout: 244 seconds]
slemonide has joined #racket
slemonide has quit [Client Quit]
dented42 has joined #racket
endobson has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
slemonide has joined #racket
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
slemonide has quit [Client Quit]
dented42 has joined #racket
dented42 has quit [Ping timeout: 244 seconds]
rnmhdn has joined #racket
g00s has quit [Quit: Textual IRC Client: www.textualapp.com]
dented42 has joined #racket
rnmhdn has quit [Quit: WeeChat 2.2]
rnmhdn has joined #racket
iyzsong has quit [Ping timeout: 268 seconds]
ziyourenxiang has joined #racket
dented42 has quit [Ping timeout: 260 seconds]
soegaard has joined #racket
rnmhdn has quit [Ping timeout: 268 seconds]
dan_f has quit [Quit: dan_f]
mzan has joined #racket
dented42 has joined #racket
SenasOzys has joined #racket
iyzsong has joined #racket
rnmhdn has joined #racket
rnmhdn has quit [Ping timeout: 252 seconds]
rnmhdn has joined #racket
rnmhdn has quit [Ping timeout: 246 seconds]
orivej has joined #racket
jao has joined #racket
SenasOzys has quit [Quit: Leaving]
dented42 has quit [Ping timeout: 252 seconds]
dddddd has joined #racket
rntz has joined #racket
<rntz> is there anything vaguely like GADTs for contracts? or, just a way to make a collection of contracts indexed by a collection of values, but also get the "erased" contract that gives the union across all possible values?
<rntz> e.g. I want val/c such that (val/c 'num) = number?, (val/c 'bool) = boolean?, and some way to extract anyval/c == (or/c number? boolean?)
lavaflow has quit [Ping timeout: 252 seconds]
ubLIX has joined #racket
Fernando-Basso has joined #racket
iyzsong has quit [Read error: Connection reset by peer]
pierpal has quit [Ping timeout: 252 seconds]
stchang has quit [Ping timeout: 252 seconds]
gabot has quit [Ping timeout: 245 seconds]
gabot has joined #racket
dented42 has joined #racket
pierpal has joined #racket
lavaflow has joined #racket
pierpal has quit [Ping timeout: 268 seconds]
_whitelogger has joined #racket
dented42 has quit [Ping timeout: 260 seconds]
iyzsong has joined #racket
dented42 has joined #racket
selimcan has joined #racket
Arcaelyx has quit [Ping timeout: 264 seconds]
Arcaelyx_ has joined #racket
dented42 has quit [Ping timeout: 272 seconds]
iyzsong-x has joined #racket
iyzsong has quit [Ping timeout: 264 seconds]
pierpal has joined #racket
dented42 has joined #racket
iyzsong-x has quit [Ping timeout: 272 seconds]
dented42 has quit [Ping timeout: 246 seconds]
<samth> rntz: that would be relatively easy to implement, but doesn't exist that I know of
rnmhdn has joined #racket
pera has joined #racket
dented42 has joined #racket
jrslepak has quit [Ping timeout: 245 seconds]
jrslepak has joined #racket
wpcarro has joined #racket
<wpcarro> I'm new to Racket, but I'm experimenting with it currently to test out a "hello, world"-like example for concurrency. I was hoping to re-create a problematic example where two threads attempt to increment a shared variable 10x each. The goal is to have the end result not always equal 20. I haven't been able to accomplish this, however, because it seems like Racket's runtime prevents this with atomic
<wpcarro> `set!`. Is that a correct assumption?
pera has quit [Ping timeout: 246 seconds]
pera has joined #racket
<wpcarro> I was hoping to use Racket to construct a pedantic walkthrough of semaphores and mutexes. But if I can't recreate the problematic scenarios, I might have to switch to another language that will let me shoot myself in my foot. I'd be sad to leave Racket though :/
<soegaard> No. But you in, say, (set! x (+ x 10)) you have to be extremely lucky/unlucky for the system to switch between threads right after (+ x 1) and before (set! x ...)
<soegaard> So you can for example introduce a delay to observe what you are after.
<soegaard> (set! x (let ([y (+ x 1)]) (sleep 1) y)
<soegaard> And perhaps let the pause be small in one thread and large in the other.
<wpcarro> soegaard: hm interesting. I'll try this out. I read that "set! assigns to a variable as an atomic action with respect to all threads..." I was wondering if this was then a deal-breaker for me
<wpcarro> I'm still new to some of these details, so my understanding my be misleading me
<soegaard> I'll look up set! to see what it says.
<lexi-lambda> The assignment is atomic, but there’s no guarantee that the evaluation of the RHS and the assignment together is a single atomic operation.
<soegaard> ^ +1
dented42 has quit [Ping timeout: 268 seconds]
<lexi-lambda> The guarantee is just that you will never have partial reads/partial writes.
<lexi-lambda> You could make a version of set! that non-deterministically introduces delays to increase the likelihood of pathological scenarios for the purposes of demonstrations, random testing, etc.
<wpcarro> lexi-lambda: ah okay then. That's the part I'm struggling to understand. Racket's docs mentioned "half-assigned" variables. I tried to read more about this online, but couldn't find anything
<lexi-lambda> Yes, `set!` guarantees that you will never end up with a “half-assigned” variable. This is, in a language like Racket, a fairly weak guarantee.
<wpcarro> lexi-lambda: what might a half-assigned variable look like..? I'm having trouble imagining the scenario
<lexi-lambda> Imagine for a moment some low-level language with a memory model like C’s, where values are just blobs of bits. It would be possible to imagine a non-atomic write operation where assigning to a value might overwrite the bits one-by-one, and theoretically, some other thread could read the data in the middle of the writing.
<lexi-lambda> So if you had some 32-bit integer, perhaps some of the high bits would have changed when you read, but the low bits haven’t yet, producing a value that is neither the old value nor the new one.
<lexi-lambda> In Racket this makes less sense, since values are not, conceptually, blobs of bits, and their representation in memory is opaque. So a “half-written” value wouldn’t be a Racket value at all, it’d just be garbage. The runtime prevents this from happening.
<wpcarro> ah ha! Okay that makes a lot of sense. So if assignment isn't atomic, partial values become a concern
<lexi-lambda> Right. So Racket doesn’t guarantee that (set! x (add1 x)) will atomically increment x by 1, only that reads from x cannot happen “in the middle of” the assignment, so you’ll only ever get back the new value or the old value.
<wpcarro> lexi-lambda: okay and the "middle" being that "garbage" state that you alluded to? If so, this makes complete sense. Hence - why you called it a weak guarantee
<wpcarro> Is that right?
<lexi-lambda> Yes, that’s right.
<wpcarro> wow. fascinating
<wpcarro> Thank you
<lexi-lambda> Admittedly, as soegaard mentions, it’s probably very unlikely that the Racket thread scheduler would switch threads between evaluating (add1 x) and performing the assignment, and indeed, I’m not sure if it ever would. But if the RHS were some more complicated operation, there might be a switch between reading x and writing x.
<lexi-lambda> Since Racket threads don’t actually run in parallel, the possibility of two parallel processes interleaving reads/writes is impossible.
<wpcarro> lexi-lambda: yeah I could see cyclomatic complexity or some other metric being useful to a thread scheduler determining if it might want to switch after evaling the RHS... maybe
<wpcarro> lexi-lambda: hm is that to say then that the example I'm trying to illustrate is a fool's errand?
<lexi-lambda> Even if it is possible (it might be, I’m not sure), it seems monumentally unlikely to ever fail in the way you’re looking for. But you could construct slightly different programs (albeit more complicated ones that obscure what you’re trying to demonstrate) that produce the behavior you want.
<wpcarro> lexi-lambda: hm okay... maybe I'll try writing in something without a runtime like C to give me a more free-fall environment
<lexi-lambda> wpcarro: This program, for example, consistently gives me different answers. http://pasterack.org/pastes/96537
<soegaard> Oh - I am too slow !
<lexi-lambda> No, not too slow: my example doesn’t define a new set!. :)
<wpcarro> both examples are super helpful! Will need to break these down over the next 30mins or so. But very promising. Thank you both
<wpcarro> Racket so far has been a totally pleasant dev exp. ... any companies hiring Racket devs? *gulp*
<wpcarro> Tools like pasterack that are linking to the docs... so cool! My emacs `racket-mode` is sensational as well
<wpcarro> soegaard: thanks for this
<soegaard> Note the policy.
<wpcarro> too cool
<wpcarro> thanks again
jao has quit [Ping timeout: 272 seconds]
ziyourenxiang has quit [Ping timeout: 268 seconds]
ubLIX has quit [Quit: ubLIX]
dented42 has joined #racket
rntz has left #racket [#racket]
rntz has joined #racket
pera has quit [Ping timeout: 244 seconds]
dan_f has joined #racket
rnmhdn has quit [Ping timeout: 244 seconds]
rnmhdn has joined #racket
dented42 has quit [Ping timeout: 264 seconds]
wpcarro has quit [Quit: Lost terminal]
<rntz> why is there equal-secondary-hash-code but no eq-secondary-hash-code?
<rntz> reason I ask: I want to make a structure which compares equal? only if its contents are eq?
<rntz> so I need to implement gen:equal+hash, which requires implementing two hash procedures
<rntz> and I'm wondering whether it's okay to have them both be identical & based on eq-hash-code
pera has joined #racket
selimcan has quit [Quit: Leaving]
<soegaard> rntz: because eq implies the pointer is enough to hash ?
Diagon has quit [Read error: Connection reset by peer]
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #racket
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #racket
rnmhdn has quit [Ping timeout: 252 seconds]
rnmhdn has joined #racket
pera has quit [Ping timeout: 268 seconds]
jao has joined #racket
rnmhdn has quit [Ping timeout: 252 seconds]
Diagon has joined #racket
libertyprime has quit [Ping timeout: 244 seconds]
pierpal has quit [Remote host closed the connection]
soegaard has quit [Quit: soegaard]
Diagon has quit [Read error: Connection reset by peer]
Fernando-Basso has quit [Remote host closed the connection]
libertyprime has joined #racket
Diagon has joined #racket
orivej has quit [Ping timeout: 272 seconds]
orivej has joined #racket
Sauvin has quit [Ping timeout: 252 seconds]
sauvin_ has joined #racket
sauvin_ is now known as Sauvin
orivej has quit [Ping timeout: 246 seconds]
groovy2shoes has joined #racket
pera has joined #racket
Diagon has quit [Ping timeout: 268 seconds]
dan_f has quit [Quit: dan_f]
widp has quit [Quit: WeeChat 2.1]
ym has joined #racket
ym has quit [Remote host closed the connection]
orivej has joined #racket
mzan has left #racket [#racket]
dan_f has joined #racket
zigpaw has quit [Ping timeout: 260 seconds]
badkins has joined #racket
badkins has quit [Remote host closed the connection]
dan_f has quit [Quit: dan_f]
dan_f has joined #racket
pie_ has joined #racket
pera has quit [Ping timeout: 240 seconds]
dan_f has quit [Quit: dan_f]
zigpaw has joined #racket
P1RATEZ has joined #racket
dan_f has joined #racket
pera has joined #racket
dan_f has quit [Quit: dan_f]
dan_f has joined #racket
ubLIX has joined #racket
wingsorc has joined #racket
pera has quit [Ping timeout: 246 seconds]
ZombieChicken has joined #racket
dan_f has quit [Quit: dan_f]
dan_f has joined #racket
FreeFull has quit [Quit: rebooting]
dan_f has quit [Client Quit]
<samth> rntz: yes, that's fine (and it's ok if the secondary hash code is the same is the primary, it's just not as good a hash as possible)
aeth has quit [Read error: Connection reset by peer]
aeth has joined #racket
FreeFull has joined #racket
g00s has joined #racket
dan_f has joined #racket
pie_ has quit [Ping timeout: 260 seconds]
montokapro has joined #racket
dan_f has quit [Quit: dan_f]