Annotating OCaml Variables and Returns with local_ | OCaml Unboxed

Ғылым және технология

This is the second installment in the video series explaining OCaml's locals.
In this video, I explain how we can annotate variables and return types with local_.
Code for this video: github.com/goldfirere/janestr...
View instructions to get the compiler I use in this video: github.com/janestreet/opam-re...
Playlist for videos in this series: • OCaml Unboxed

Пікірлер: 8

  • @Metruzanca
    @Metruzanca5 ай бұрын

    Would love more of these ocaml unboxed

  • @JeanNoelAvila
    @JeanNoelAvila6 ай бұрын

    Very interesting! Maybe a dumb question: why annotate when the compiler can check whether the variables do not escape their context?

  • @RichardEisenberg-JS

    @RichardEisenberg-JS

    6 ай бұрын

    By annotating, we can check whether our belief meets reality, turning a mistaken belief into a compile-time error. Annotating also informs future readers of our code and makes the code easier to understand.

  • @JeanNoelAvila

    @JeanNoelAvila

    6 ай бұрын

    @@RichardEisenberg-JS Thank you. Is the stack allocation not implemented if it is not annotated?

  • @RichardEisenberg-JS

    @RichardEisenberg-JS

    6 ай бұрын

    @@JeanNoelAvila Inferring stack allocation (not covered in depth in the video, but it will be!) works just fine. You don't need to annotate for that.

  • @adicide9070
    @adicide90705 ай бұрын

    Do you know if this stuff will be part of the language?

  • @RichardEisenberg-JS

    @RichardEisenberg-JS

    5 ай бұрын

    I know we will work with the OCaml community maintainers to get this to be a part of the language -- but not for a while. Our approach is to experiment locally (ha ha) here at Jane Street, gain experience about what's good and what's bad, and then to work to upstream when we have more confidence. In the end, language design is hard to get right, and we want to take advantage of the fact that we can somewhat easily undo mistakes before this is all part of the official language.

  • @adicide9070

    @adicide9070

    5 ай бұрын

    @@RichardEisenberg-JS aaah the puun! :D nice to watch though. not sure if OCaml can get more popular and widely adopted at this point but ML is the bomb, so here's hoping something ML does!

Келесі