Live data from Hacker News

OCaml on Baremetal Shakti RISC-V Processor

kcsrk.info

71–77 of 77 posts

Re: OCaml on Baremetal Shakti RISC-V Processor

#71
post #56

Earlier quoted context omitted.

> and not so good at floating point computations What does this mean? I was under the impression the OCaml compiler did a decent number of floating point specific optimizations, like unboxed arrays and what not.

I guess it is the typical complain about using separate operators for ints and floats. It never bothered me in Caml Light, let alone when Objective Caml was introduced.

You can write floating point operators in several different ways. You can write with the normal floating point operators

    x *. y +. z
or, since `Float.(+) = (+.)`, `Float.() = (.)`, etc,

    let open Float in
    x * y + z
or simply

    Float.(x * y + z)

Re: OCaml on Baremetal Shakti RISC-V Processor

#72
post #23

Earlier quoted context omitted.

OCaml is very good at symbolic computations, and not so good at floating point computations. Therefore it's a very good language for writing compilers etc. Further than that, there are no more programs written in it for the same reason than there are no more programs written in any interesting languages, I guess; ie largely accidental.

> and not so good at floating point computations What does this mean? I was under the impression the OCaml compiler did a decent number of floating point specific optimizations, like unboxed arrays and what not.

Symbols (variants with our without parameters) and integers are unboxed, while floats are not (but in a few specific cases such as arrays of floats, and iiuc that's an inelegant special case on its way out, as it prevents other optimisations).

Re: OCaml on Baremetal Shakti RISC-V Processor

#74
post #71
post #56

Earlier quoted context omitted.

I guess it is the typical complain about using separate operators for ints and floats. It never bothered me in Caml Light, let alone when Objective Caml was introduced.

You can write floating point operators in several different ways. You can write with the normal floating point operators x *. y +. z or, since `Float.(+) = (+.)`, `Float.( ) = ( .)`, etc, let open Float in x * y + z or simply Float.(x * y + z)

That is pretty neat. Does it mean that one could do something similar for vectors and quaternions?

    let open Quaternion in
    x * y + x

Re: OCaml on Baremetal Shakti RISC-V Processor

#75
post #74
post #71

Earlier quoted context omitted.

You can write floating point operators in several different ways. You can write with the normal floating point operators x *. y +. z or, since `Float.(+) = (+.)`, `Float.( ) = ( .)`, etc, let open Float in x * y + z or simply Float.(x * y + z)

That is pretty neat. Does it mean that one could do something similar for vectors and quaternions? let open Quaternion in x * y + x

Yes.

Re: OCaml on Baremetal Shakti RISC-V Processor

#77
post #74
post #71

Earlier quoted context omitted.

You can write floating point operators in several different ways. You can write with the normal floating point operators x *. y +. z or, since `Float.(+) = (+.)`, `Float.( ) = ( .)`, etc, let open Float in x * y + z or simply Float.(x * y + z)

That is pretty neat. Does it mean that one could do something similar for vectors and quaternions? let open Quaternion in x * y + x

Yep. You could write

    module Quaternion = struct
      let (+) =
        ...
    
      let ( * ) =
        ...
    end
then

    let open Quaternion in
imports the contents of Quaternion into local scope, so you can write

    x * y + z
Post reply on HN