@jgeddes has joined the channel
@poga.po has joined the channel
@sjaniska has joined the channel
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.
Is there any typed variant for the ffi/unsafe
library?
OK I’ve found this https://felleisen.org/matthias/manifesto/sec_full.html
documentation of timer% (Racket 7.8)
(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?
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
Racket is unlike other languages. You can’t add more parentheses and expect it to change no meaning
What are you trying to do?
I know that. I am pointing out a difference between the docs and what works. Did you read my post?
The error occurs when the structure in the docs is used.
Ah, you are talking about the doc
Sorry, I missed that
As my post said
So, this is a little bit subtle, but the brackets in the doc are different
(new timer%
[ [notify-callback notify-callback]
[interval interval]
[just-once? just-once?]])
The outer one means “optional”
Makes no difference if they are [ or (
The inner one is syntactic
what?
So that means, you can simply write (new timer%)
and that would work
because stuff inside the outer bracket is optional
The bracket means optional
Again, this is a little bit subtle. It is typeset a little bit differently
That’s dreadful - yes it is typeset differently - darker. It’s not a question of subtlety but clarity thanks for pointing that out.
But I guess not many people see it
> The brackets surrounding the in argument in the application syntax indicates that it is an optional argument.
> 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.
yep - got it.