Meaning of xf

They are just arbitrary variable names with no special significance.

Take a look at the manual for more info on do block syntax and also see this discussion.

In short, do blocks are an alternative syntax for creating and passing an anonymous function as the first argument to another function. The following are equivalent:

foo(x -> bar(x), y) # anonymous function with `->` syntax

# is equivalent to

foo(
    function (x) # notice that we didn't give this function a name
        bar(x)
    end,
y) # anonymous function with `function` syntax

# is equivalent to

foo(y) do x
    bar(x)
end # anonymous function created and passed via `do` syntax

There isn’t any significance to the name x here, it’s just the name given to the argument of the anonymous function. The xf and f in your case are similarly just names.

In this case, based on (what I’m guessing about) the XLSX.openxlsx function, I’m betting that they are file handles that can be used to access the contents of the file. The reason that an anonymous function is used here is to ensure that the file gets closed once the code is done reading it (or, importantly, if it stops reading because it throws an error).

4 Likes