Docs about annotations?


#1

Hi all

Where can I find a good explanation about annotations for example @bs.val, @bs.module, @bs.send, etc?
I’ve found https://bucklescript.github.io/bucklescript/Manual.html#_binding_to_a_value_from_a_module_code_bs_module_code

But I am not sure, if it is up-to-date.

Thanks


#2

@bs.module https://bucklescript.github.io/docs/en/import-export.html
@bs.val https://bucklescript.github.io/docs/en/bind-to-global-values.html
@bs.send https://bucklescript.github.io/docs/en/function.html#object-method


#3

Sorry for being naive about OCaml terminology. But what are these special looking annotations in OCaml world? So far, I have seen @bs.val, @bs.module, @bs.send, @bs.send, @bs.meth, [@bs.deriving abstract], etc.

What are these entities called? Are they similar to decorators that we see in other languages? Is that syntax specific to BuckleScript or general compiler directives for OCaml or some sort of native language construct? I could not Google it as I do not really know what I should be looking for.

Any link explaining this concept would be great.


#4

Hi, in general these annotations are called extension points and they tell the compiler to transform the parsed syntax tree in a particular way. So they are pretty similar to macros, in a limited way. Here’s a good write-up: https://victor.darvariu.me/jekyll/update/2018/06/19/ppx-tutorial.html