
Hi all. It seems that the following let binding syntax are the same. (let ([x 5] x)) ;; uses square brackets to bind variable (let ((x 5)) x) ;; uses parantheses to bind variable


square brackets == parentheses. It’s just something people use to visually key different parts of code in their own way

They aren’t syntactically different like in clojure

Yes. In standard Racket (), [] and {} mean the same.

For example [define x 10]
is just fine

Oh wow!! I did not know that.

Usually [] is used to indicate pairings such as in let and in cond.

It threw me off for a while there!

The () is used to group a sequence of pairings.

But, just a convention.

But in racket, you create a vector with [ … ] correct?

no. #(1 2 3)
is a vector

I usually use [
to indicate… non-evaluated forms or pairs. For example:
(match thing
[(list x xs ...) x]
[_ 'foo])
The [
pairs the pattern with the result and the car of the pair isn’t a function call. While anywhere I use (
I can assume the head item is applied.

That’s just me, though. Everyone likely has their own brand of how they use them. In the end, though, as @soegaard2 said, they’re all the same.

Yeah, create a new vector with vector
make-vector
for/vector
or use a vector literal #(1 2 3)
. Literals are only created once, so beware of mutating them.

Thanks all. These explanations have helped a lot!

Keep in mind that’s all true for #lang racket
and most “normal” langs, as well as most macros.
But Racket does let a lang or macro distinguish the delimiters if it wants to. One example is #lang scribble
where []
and {}
are distinguished.
So the TLDR is definitely, yes, by default they mean the same. And it’s a convention or personal choice which to use, where. (But someday you might use or create a macro or lang where they’re not the same.)

@jeremy.german has joined the channel

Is there a special provide
form for generic struct interfaces? Or would I need to use all-defined-out
?

I guess I’d just list the methods.

But there is not something like struct-out
for generics. Although it would be reasonable to write one.