Plied Lambda Twentifold
In my defence I couldn’t resist. @soegaard2 LURED me with the promise of Racket content.
Hi, can someone explain me what this error means? racket-7.8.0.9/share/pkgs/typed-racket-lib/typed-racket/infer/promote-demote.rkt:32:0: Rep-variances: contract violation:
expected: Rep?
given: #f
argument position: 1st
I get this with following program #lang typed/racket/base
(require racket/sequence)
(define (fun [vs : (U (Sequenceof (Sequenceof Real))
(Sequenceof (Sequenceof (Sequenceof Real))))])
(for/fold ([result : (Option (Listof (Pair (Vectorof Real)(Vectorof Real)))) '()]
[firstok : Boolean #f]
#:result result)
([s vs]
#:break (not result))
(define l (sequence->list s))
(cond
[(and firstok (= (length l) 2) (sequence? (car l)))
(values (cons (cons (list->vector (sequence->list (car l)))
(list->vector (sequence->list (cadr l))))
result)
firstok)]
[firstok
(raise-argument-error 'arrows "Sequence of Sequence (of 2 elements) of Sequence (of 2 Reals)" vs)]
[(and (= (length l) 2) (sequence? (car l)))
(values (cons (cons (list->vector (sequence->list (car l)))
(list->vector (sequence->list (cadr l))))
result)
#t)]
[else (values #f #f)])))
That’s a typed racket bug
by definition
Should I make a report?
Yes
So it looks like for simple syntax error (like unbound identifiers) Racket offers a stack trace that contains a lot of temporary functions and the guts of the macro expander. Is there any way to hide those? I feel like they cause beginners to distrust Racket error messages
Or any stack trace in general. Here’s one I got recently:
p
call-in-empty-metacontinuation-frame
check-break-prefix
call-with-empty-metacontinuation-frame-for-swap
l
loop
dynamic-wind
temp52_0
/Users/sorawee/git/racket/racket/collects/setup/parallel-do.rkt:236:4
dynamic-wind
/Users/sorawee/git/racket/pkgs/racket-index/setup/scribble.rkt:138:0: setup-scribblings
call-in-empty-metacontinuation-frame
winder-dummy
/Users/sorawee/git/racket/racket/collects/setup/setup-core.rkt:72:0: setup-core
call-in-empty-metacontinuation-frame
body of "/Users/sorawee/git/racket/racket/collects/setup/main.rkt"
Probably l
, p
, and temp52_0
could be elided.
I think an algorithm for how to tell is the main thing missing.
Don’t show stack traces for bugs beginners usually have, and add a command line flags that Racket devs can use to see the guts when they’re working on the macro expander?
For syntax errors I think the “no stack trace” approach is reasonable; I was more thinking of @sorawee’s comment
Although the trouble with exn:fail:syntax
doesn’t print stack traces is that plenty of syntax errors don’t have good source locations, in which case it’s hopeless
But overall, it might well be an improvement.
I can imagine that any code built into the Racket executable could be given a source location that makes it suppressed. That would take care of the expander noise that started showing up when the expander moved to Racket, and the even greater noise in Racket CS. That is, the current implementation of stack traces was set up for a world where built-in things rarely showed up in traces, and we could try moving back to that (without porting the code back to C, obviously).
@mflatt do you know of instances where the stack trace in an exn:fail:syntax
is worth printing the default mode (even apart from the built-in portions)?
It’s sometimes helpful to me where it’s the macro that is broken and the trace helps identify the path to an incorrect or unhelpful error, but my perspective on these points is skewed.
Right, I think we would definitely want the ability to see those stack traces, but maybe the default printing should be more like exn:fail:user
.
Can anyone try this really quick? Run the racket
REPL, type a
, and hit tab to autocomplete it. Are there any weird entries in it? I found abstractq
, abstractQ
, arithmetic-shift�
, augment*i
, and augride*1
in the list.
I see some weird ones, but not exactly those
I see mangled endings in CS and not BC. It might be that byte strings in CS don’t have an implicit NUL terminator (as exposed by the FFI) like they do in BC.
That’s what I see too
What’s this autocomplete? I type TAB, I get TAB.
What OS and Racket version are you using? And is it minimal Racket or regular Racket?
Nothing happens when I hit TAB here (DrRacket 7.8 on Windows 10).
It must be in command-line, not DrRacket
I don’t get tab autocomplete in DrRacket? (vanilla 7.8 macos catalina)
Ctrl+/
would love to bind it to tab
Hmm. Tab currently isn’t bound to anything.
alt-tab flips between definitions and interactions Ctrl-tab switches Tab(currently selected file) Tab - noting not even tab characted
Tab in DrRacket is bound to autoindent
I forgot!
yay! I can override tab to indent and get tab to autocomplete #lang s-exp framework/keybinding-lang
(keybinding "tab" (λ (editor evt) (send editor auto-complete)))
@liquidcloud9 has joined the channel
Asked this on Reddit, but couldn’t find an answer. Does Racket have something similar to CL’s DESCRIBE and INSPECT?
I implemented a value browser for symbolic terms in Rosette, but it could be used for Racket values as well:
https://docs.racket-lang.org/rosette-guide/sec_utility-libs.html
This is great! Thank you for the help.
Good evening. If I’d like to disable TLS 1.0, TLS 1.1 and SSL 3.0 in the Racket Web Server, is that possible?
I don’t think there’s a configuration option for that at the moment.
Probably you’d need to expose something about ssl contexts from server/servlet
and then use ssl-set-cipher
Thanks, samth. I cross-posted the question to discord.racket.general. Jay McCarthy answered pointing out that I could change web-server-lib/web-server/web-server.rkt, line 74, procedure make-ssl-connect@, which invokes ports->ssl-ports, which belongs to openssl, and has a keyword #:protocol with which we can set the protocols we want to use. (Turns out the documentation mentions keyword #:encrypt, which is wrong. So I’m actually going to fix the documentation. The right question to the catch the doc flaw. :P)
Question probably for @mflatt and @ryanc
Say, I fully expand a syntax object and extract an identifier from it (along with those hidden in 'disappeared-use
and 'origin
properties) and test free-identifier=?
with a similar id from phase 0 in another module
Continued in subthread
Situation 1: When that identifier is syntax-case
, and the program is:
#lang racket/base
(syntax-case 1 ()
[_ 2])
I found that (free-identifier=? new-id extracted-id)
where new-id
= #'syntax-case
at (a-phase-level, b-phase-level) = (0, 0) and (1, 1)
Situation 2: consider:
(require (for-syntax racket/base))
(define-syntax (foo stx)
(syntax-case 1 ()
[_ 2]))
results in
(free-identifier=? new-id extracted-id)
at (a-phase-level, b-phase-level) = (0, 0) and (0, 1)
Situation 3: let’s change the identifier to ~literal
from syntax/parse
. Doing the same thing with
(require syntax/parse)
(syntax-parse 1
[(~literal a) 2])
results in
(free-identifier=? new-id extracted-id)
at (a-phase-level, b-phase-level) = (1, 0) and (1, 1)
Situation 4: consider
(require (for-syntax syntax/parse
racket/base))
(define-syntax (foo stx)
(syntax-parse 1
[(~literal a) 2]))
results in
(free-identifier=? new-id extracted-id)
at (a-phase-level, b-phase-level) = (0, 0) and (1, 0)
I seem to get different answers in each situation… what’s going on?
I think I understand why situation 1vs2 and 3vs4 give different answers, but I thought 1vs3, and 2vs4 should give similar result. They don’t.
My initial guess is that you’re seeing the effect of phase shifts not reaching properties — one of the problems with having syntax objects in properties. I’d have to look more closely to be sure of that, though.
can someone explain to me escape continuations? from the https://docs.racket-lang.org/reference/cont.html?q=let%2Fec#%28def._%28%28quote._~23~25kernel%29._call-with-escape-continuation%29%29\|documentation , i think it says that you cannot call it from outside the procedure passed to call/ec
also i dont get why it matters that it isnt called from tail position… can someone explain to me?
in another note, should there be a #help channel? or would that be overkill?
IIUC, With call/cc, you can save the continuation (e.g., set! a variable to the continuation value) and then invoke it outside of the dynamic extent of call/cc. You can even invoke it multiple times!
This means that racket needs to copy frame information to a data structure so that you can invoke the continuation later
But for call/ec, you are only limited to call it at most once during the dynamic extent of the form
So racket doesn’t need to copy frame information = more efficient
I belive in RacketCS the situation is reversed: call/ec is less efficient
oooh ok, thank you!
there was this thread the other way and it makes me wonder https://racket.slack.com/archives/C09L257PY/p1598119755040700
While reviewing a pull request for the plot package, the author has used an undocumented feature of skipping lines in a line renderer. Basically, given the code:
#lang racket
(require plot)
(define skip '(+nan.0 +nan.0))
(plot (lines `((0 0) (1 1) (2 -1) (3 1) ,skip (4 -1) (5 1) (6 -1)) #:y-min -2 #:y-max 2))
it will produce the following plot
Looking at the source code, this seems to be to be unintended behavior, and I am wondering if anyone knows about it?
BTW, if you just learned about this from my message, don’t use it — I intend to keep this as undocumented behavior and might change in the future. If you need two sets of lines on the plot, you can already do that by using lines
twice.