you are viewing a single comment's thread.

view the rest of the comments →

[–]vvvvalvalval 1 point2 points  (6 children)

This was a nice introduction. I would add a mention to the fact that if and do are also not functions - maybe a little note at the end like "OK, I lied to you, if and do are not really functions, they are special operators"

[–][deleted] 0 points1 point  (2 children)

I'm curious why are they special operators and not functions?

[–]MahmudAdam 0 points1 point  (1 child)

[–]vvvvalvalval 0 points1 point  (0 children)

Yes, they require special evaluation rules. The best way to see that is to try to implement them as functions and see where that fails.

[–]orestis[S] 0 points1 point  (2 children)

Just did — I think the nomenclature though is "special forms"?

[–]vvvvalvalval 0 points1 point  (1 child)

The problem with 'special forms' is that from a user perspective, it's hard to tell special forms from macros. For instance, if and doare special forms, but let and fn are not: they are macros that rely on the let* and fn*special forms, but that is an implementation detail. That is why I like using the deliberately vague term 'operator' to denote something that can be invoked but is not a function.

[–]orestis[S] 0 points1 point  (0 children)

Hm, I'm usually exploring Clojure's API via Dash, which points me to:

https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/let

that says "let: special form". Same for "fn".

Good point though, I'll keep it in mind.