I am reading the code in the "Pkg" internal package. In there, I see a 
function, genfile defined with the prototype below. 

function genfile(f::Function, pkg::String, file::String, force::Bool=false)

This is the only definition of a genfile function/method I can find in all 
of Julia's source files.I show one of the calls to genfile at the end of 
this message. Notice that although the definition of genfile takes 4 
parameters, the call below, and all the calls I found, all provide only 3 
arguments. The first argument of type Function is never supplied. I don't 
understand how this can be "legal".

Is there some syntax rule allowing this that I did not notice in the 
manual? I don't think so. Is the "genfile(...) do io" form of the call 
implies providing some kind of function as the first parameter by magic? 
This one is really throwing me out for a loop. What is going on there?

    genfile(pkg,"LICENSE.md",force) do io
        if !haskey(LICENSES,license)
            licenses = join(sort!([keys(LICENSES)...], by=lowercase), ", ")
            error("$license is not a known license choice, choose one of: 
$licenses.")
        end
        print(io, LICENSES[license](pkg, string(years), authors))
    end || info("License file exists, leaving unmodified; use `force=true` 
to overwrite")

Reply via email to