
What’s a definition context? Why is begin
not a definition context?

A body
contains a series of definitions-or-expressions followed by an expression. For example . (lambda () (define a 42) (+ a 1))

The begin
form does not create a new scope, so if your begin
is in an expression position, it can not contain definitions.

I see, thanks.

The begin
is handled specially by the expander. So if your begin is in a definition context
, then the begin
form can contain definitions. (lambda () (begin (define a 42)) (+ a 1))

The expander will simple rewrite this to: (lambda () (define a 42) (+ a 1))

This is known as “splicing”.

My begin was in a expression context (if statement), that’s why I got the error. Anyways, I moved up my definition to the nearest definition context without problems.

FWIW, you can create an internal-definition context by (let () put-stuff-here)

For Rhombus (the next generation of Racket), I have been proposing that the current behavior of begin
is harmful and it should be renamed to something else: https://github.com/racket/rhombus-brainstorming/issues/87

Did you check the discussion on begin
on the rrrs-authors mailing list?

Nope

Can you point me to it?

I was not aware that there’s a discussion

I recall reading about sequence
vs begin
. It’s in the archive. Somewhere …

There are a few threads here: https://groups.csail.mit.edu/mac/ftpdir/scheme-mail/HTML/rrrs-1986/threads.html


Oh well, it’s started as an April Fools’ joke

What?

I totally missed that :slightly_smiling_face:

there’s also block
which is more like what you want begin
to be

begin
is usually what you want when writing macros, block
is usually what you want everywhere else

It’s not happy about rash.

Same error on rebellion

Checking that my bespoke Dockerfile is setting up Racket the same as @notjack ’s

Yeah it’s setting up the same catalogs

@soegaard2 thank you earlier for hinting me about basic blocks. it has improved made it nearly twice as fast in tight loops, and no less than 50% in other places!

Huh, maybe the dockerfiles don’t set up that catalog. Haven’t looked at them in a while.

Info about the built package catalog is at https://pkg-build.racket-lang.org/about.html\|https://pkg-build.racket-lang.org/about.html

The catalog it should be using is https://pkg-build.racket-lang.org/server/built/catalog/\|https://pkg-build.racket-lang.org/server/built/catalog/

Is there a graph library (A graph with vertices and edges, not charts) that works with typed racket?

If not a library, then some reference implementation so I could avoid re-implementing common things?

I imagine you could use require/typed
with Stephen Chang’s graph library. (In fact, the ~typed racket~ gradual typing benchmarks do that, I think…)

Do you happen to have a link to these benchmarks? I could take the type definitions from there instead of reworking them


Thanks, this looks promising!

yep it’s using that one

There is also the shared library which comes with racket to build graphs with normal racket data structures, which can then be typed. https://docs.racket-lang.org/reference/shared.html?q=shared#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29

Is there a way to say what order the catalogs should be tried in? The console output you gave made it seem like the regular catalog was tried first and the built-package catalog wasn’t tried at all

I’m guessing raco pkg
doesn’t know how to fallback to another catalog if one has the package, but not in precompiled form

That’s an idea. I’ll try that.