
New racket stickers for the laptop


Quickscript competition 2020 and small racket logo

You’ll soon need a new laptop to put more stickers!

I will!

@dynapate has joined the channel


hello I have a silly question ..

I have read this >A thread cell can be preserved; when a new thread is created, the creating thread’s value for a preserved thread cell serves as the initial value for the cell in the created thread. For a non-preserved thread cell, a new thread sees the same initial value (specified when the thread cell is created) as all other threads. my question is ,what the “thread cell” is? and what this mean “the creating thread’s value for a preserved thread cell serves as the initial value for the cell in the created thread”,can someone write some code to explain it,thanks

@enyala9733 A thread (process) A running a program P can start another thread B running the same program. For a standard variable x whose value is stored in some location (memory cell) the location is shared between the two threads. If process B writes a value to x, then thread A can see the value, when x is referenced.
A thread cell also contains a value that can be referenced and stored to. But when the thread B is created, all thread cells of A is copied to create a new set of thread cells for B. The initial values will the whatever was stored in the thread cells of A.
Now when a the thread B stores a new value into a thread cell, only the B can se the change.
That is: standard variables are shared between threads and thread cells are not.

Now the story above holds for preserved thread cells.

I.e. when a new thread is created the current value of the thread cell is used.

In the case of a non-preserved thread cell, the current value isn’t copied - but the original value supplied when the thread cell was created is used.

I’ll try to write an example.

thanks for reply ,wha’s the different between thread cell and c++’s <https://docs.microsoft.com/en-us/cpp/parallel/thread-local-storage-tls|Thread Local Storage>?

This program: #lang racket
(define cell (make-thread-cell 'original #t))
(thread-cell-set! cell 'A)
(void
(displayln (list 'A (thread-cell-ref cell)))
(thread (λ() (displayln (list 'B (thread-cell-ref cell))))))
prints (A A)
(B A)

maybe this will help: (define p (make-parameter #f))
(define (test)
(parameterize ([p 'alt-thread])
(thread (λ ()
(displayln (p))))
(p 'main-thread)
(displayln (p))))
(test)

lol - same idea :slightly_smiling_face:

And this program: #lang racket
(define cell (make-thread-cell 'original #f))
(thread-cell-set! cell 'A)
(void
(displayln (list 'A (thread-cell-ref cell)))
(thread (λ() (displayln (list 'B (thread-cell-ref cell))))))
prints: (A A)
(B original)

If you’ve used Common Lisp, it’s more akin to a dynamically scoped variable than thread local. Dynamically scoped variables are thread local, but the value it has when the thread is spawned is passed as the initial value to the thread as well

I’ll admit ignorance wrt C++.

in “non-preserved”,what’s the “original value supplied”

See the example below. In the example the original value is ’orignal but it can be anything you like.

(below in the main thread)

Hahaha, yes, I have seen it, no need to explain

Thank you for your sample code, I found it by searching (make-thread-cell) https://docs.racket-lang.org/reference/threadcells.html Now i know what’s going on

the apple logo shining through the racket sticker looks super cool

A case where ignorance really is bliss