Richard W.M. Jones
2021-Nov-25 15:46 UTC
[Libguestfs] [PATCH v3 4/5] daemon/parted: work around part table type misreporting by "parted"
On Thu, Nov 25, 2021 at 04:27:42PM +0100, Laszlo Ersek wrote:> It provides the following examples, and states that they are equivalent: > > let sum = fun i j -> i + j;; > let sum = (fun i -> (fun j -> i + j));; > let sum i j = i + j;; > > Why is the usage of "fun" awkward here?They are equivalent, but no one is using the "fun" form in real code because it's longer and more obscure for no reason.> Is the problem more that I used an explicit "offset" parameter, so > sec0at is not defined as a partial function application?I made two changes but didn't explain that well. Firstly get rid of the "fun" as above: let sec0at offset = Bytes.get_uint8 sec0 offset in Secondly, you can drop the argument to produce this equivalent and shorter form: let sec0at = Bytes.get_uint8 sec0 in (https://rosettacode.org/wiki/Partial_function_application#OCaml) Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Laszlo Ersek
2021-Nov-25 15:57 UTC
[Libguestfs] [PATCH v3 4/5] daemon/parted: work around part table type misreporting by "parted"
On 11/25/21 16:46, Richard W.M. Jones wrote:> On Thu, Nov 25, 2021 at 04:27:42PM +0100, Laszlo Ersek wrote: >> It provides the following examples, and states that they are equivalent: >> >> let sum = fun i j -> i + j;; >> let sum = (fun i -> (fun j -> i + j));; >> let sum i j = i + j;; >> >> Why is the usage of "fun" awkward here? > > They are equivalent, but no one is using the "fun" form in real code > because it's longer and more obscure for no reason. > >> Is the problem more that I used an explicit "offset" parameter, so >> sec0at is not defined as a partial function application? > > I made two changes but didn't explain that well. Firstly get rid of > the "fun" as above: > > let sec0at offset = Bytes.get_uint8 sec0 offset in > > Secondly, you can drop the argument to produce this equivalent and > shorter form: > > let sec0at = Bytes.get_uint8 sec0 in > > (https://rosettacode.org/wiki/Partial_function_application#OCaml)OK, thanks for explaining. I'll send a v4 later. (Probably tomorrow.) Laszlo