jgeddes
2020-8-5 09:08:29

@jgeddes has joined the channel


poga.po
2020-8-5 11:52:49

@poga.po has joined the channel


sjaniska
2020-8-5 12:52:38

@sjaniska has joined the channel


samth
2020-8-5 13:37:56

Two things: 1. There aren’t any values with type Nothing — you can only get it with something that throws an exception (or similar). 2. What I meant there is that type inference discovers that there are no constraints forcing it to choose a particular type as the return type of that function, and thus it chose Nothing. It’s not that Nothing has “no constraints” in some general sense.


yilin.wei10
2020-8-5 17:25:56

Is there any typed variant for the ffi/unsafe library?


yilin.wei10
2020-8-5 17:47:34

cawright.99
2020-8-6 05:16:31

documentation of timer% (Racket 7.8)


cawright.99
2020-8-6 05:40:20

(new timer% [ [notify-callback notify-callback] [interval interval] [just-once? just-once?]]) → (is-a?/c timer%) notify-callback : (-> any) = void interval : (or/c (integer-in 0 1000000000) #f) = #f just-once? : any/c = #f my simple example works (define clock (new timer% (notify-callback (lambda () (notify-registered-clock-clients))) (interval #f))) but if I add an extra pair of brackets around notify-callback/interval, I get a syntax error

(define clock (new timer% [(notify-callback (lambda () (notify-registered-clock-clients))) (interval #f)])) new: expected identifier in: (notify-callback (lambda () (notify-registered-clock-clients)))

I wonder what I have misunderstood in the docs?


cawright.99
2020-8-6 05:50:41

the docs are both local and at https://docs.racket-lang.org/gui/timer_.html I think this might be an error in the docs. There are some stackoverflow postings which have the syntax that works for me eg: https://stackoverflow.com/questions/44505671/how-can-i-control-my-clock-speed-using-racket


sorawee
2020-8-6 05:56:50

Racket is unlike other languages. You can’t add more parentheses and expect it to change no meaning


sorawee
2020-8-6 05:56:59

What are you trying to do?


cawright.99
2020-8-6 05:58:28

I know that. I am pointing out a difference between the docs and what works. Did you read my post?


cawright.99
2020-8-6 05:59:02

The error occurs when the structure in the docs is used.


sorawee
2020-8-6 05:59:08

Ah, you are talking about the doc


sorawee
2020-8-6 05:59:14

Sorry, I missed that


cawright.99
2020-8-6 05:59:17

As my post said


sorawee
2020-8-6 05:59:46

So, this is a little bit subtle, but the brackets in the doc are different


sorawee
2020-8-6 05:59:54

(new timer% [ [notify-callback notify-callback] [interval interval] [just-once? just-once?]])


sorawee
2020-8-6 06:00:12

The outer one means “optional”


cawright.99
2020-8-6 06:00:13

Makes no difference if they are [ or (


sorawee
2020-8-6 06:00:25

The inner one is syntactic


cawright.99
2020-8-6 06:00:35

what?


sorawee
2020-8-6 06:00:37

So that means, you can simply write (new timer%)


sorawee
2020-8-6 06:00:40

and that would work


sorawee
2020-8-6 06:00:49

because stuff inside the outer bracket is optional


sorawee
2020-8-6 06:00:54

The bracket means optional


sorawee
2020-8-6 06:01:16

Again, this is a little bit subtle. It is typeset a little bit differently


sorawee
2020-8-6 06:01:45

cawright.99
2020-8-6 06:02:11

That’s dreadful - yes it is typeset differently - darker. It’s not a question of subtlety but clarity thanks for pointing that out.


sorawee
2020-8-6 06:03:31

sorawee
2020-8-6 06:03:40

But I guess not many people see it


sorawee
2020-8-6 06:04:06

> The brackets surrounding the in argument in the application syntax indicates that it is an optional argument.


sorawee
2020-8-6 06:04:10

> The brackets around the extract-key and cache-keys? arguments indicate that they are optional as before. The contract section of the header shows the default values that are provided for these keyword arguments.


cawright.99
2020-8-6 06:05:58

yep - got it.