ronantakizawa/codereview-bench huggingface dataset:
Repository: JuliaLang/julia
File: base/tuple.jl (Julia)

Code before:
function setindex(x::Tuple, v, i::Integer)
    @boundscheck 1 <= i <= length(x) || throw(BoundsError(x, i))
    @inline
    _setindex(v, i, x...)
end

function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N}
    @inline
    return ntuple(j -> ifelse(j == i, v, args[j]), Val{N}())
end


## iterating ##

function iterate(@nospecialize(t::Tuple), i::Int=1)
    @inline
    return (1 <= i <= length(t)) ? (@inbounds t[i], i + 1) : nothing
end

keys(@nospecialize t::Tuple) = OneTo(length(t))

prevind(@nospecialize(t::Tuple), i::Integer) = Int(i)-1
nextind(@nospecialize(t::Tuple), i::Integer) = Int(i)+1

@noinline function throw_eachindex_mismatch_indices(::Tuple{}, inds...)
    throw(DimensionMismatch("all inputs to eachindex must have the same length, got $(join(inds, ", ", " and "))"))
end

function keys(t::Tuple, t2::Tuple...)
    @inline
    lent = length(t)
    all(x->length(x) == lent, t2) || throw_eachindex_mismatch_indices((), t, t2...)
    Base.OneTo(lent)
end

# this allows partial evaluation of bounded sequences of next() calls on tuples,
# while reducing to plain next() for arbitrary iterables.
indexed_iterate(t::Tuple, i::Int, state=1) = (@inline; (getfield(t, i), i+1))
indexed_iterate(a::Array, i::Int, state=1) = (@inline; (a[i], i+1))
function indexed_iterate(I, i)
    x = iterate(I)
    x === nothing && throw(BoundsError(I, i))
    x
end
function indexed_iterate(I, i, state)
    x = iterate(I, state)
    x === nothing && throw(BoundsError(I, i))
    x
end

"""

Review comment (suggestion):
```suggestion
function throw_eachindex_mismatch_indices(::Tuple{}, inds...)
    @noinline 
    throw(DimensionMismatch("all inputs to eachindex must have the same length, got $(join(inds, ", ", " and "))"))
```

Looks like we have a bootstrapping problem: `tuple` is used very early in Core.Compiler and the full Julia machinery is not yet available. Moving this inside the method definition should resolve the problem, I think

Code after:
```jldoctest
julia> Base.setindex((1, 2, 6), 2, 3) == (1, 2, 2)
true
```
"""
function setindex(x::Tuple, v, i::Integer)
    @boundscheck 1 <= i <= length(x) || throw(BoundsError(x, i))
    @inline
    _setindex(v, i, x...)
end

function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N}
    @inline
    return ntuple(j -> ifelse(j == i, v, args[j]), Val{N}())::NTuple{N, Any}
end


## iterating ##

function iterate(@nospecialize(t::Tuple), i::Int=1)
    @inline
    @_nothrow_meta
    return (1 <= i <= length(t)) ? (t[i], i + 1) : nothing
end

keys(@nospecialize t::Tuple) = OneTo(length(t))

"""
    prevind(A, i)

Return the index before `i` in `A`. The returned index is often equivalent to
`i - 1` for an integer `i`. This function can be useful for generic code.

!!! warning
    The returned index might be out of bounds. Consider using
    [`checkbounds`](@ref).

See also: [`nextind`](@ref).

# Examples
```jldoctest
julia> x = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> prevind(x, 4) # valid result
3

julia> prevind(x, 1) # invalid result
0
Repository: JuliaLang/julia
File: stdlib/Dates/src/accessors.jl (Julia)

Code before:
# https://en.wikipedia.org/wiki/Talk:ISO_week_date#Algorithms
const WEEK_INDEX = (15, 23, 3, 11)
function week(days)
    w = div(abs(days - 1), 7) % 20871
    c, w = divrem((w + (w >= 10435)), 5218)
    w = (w * 28 + WEEK_INDEX[c + 1]) % 1461
    return div(w, 28) + 1
end

"""
Year defined as ISO year. The equivalent is
`week(lastdayofyear(dt) - Day(3))`  as 28 december is always in the last week
"""
function weeksinyear(dt::DateTime)
    firstday = firstdayofyear(dt)
    lastday = lastdayofyear(dt)

    if dayofweek(firstday) == 4 || dayofweek(lastday) == 4
        return 53
    end
    return 52
end

"""
Return current ISO year as defined in
https://en.wikipedia.org/wiki/ISO_week_date
"""
function isoyear(dt::DateTime)
    thisyear = Year(dt)
    thismonth = Month(dt)
    weeknumber = week(dt)
    if weeknumber >= 52 && thismonth.value == 1
        # If it is january, then its the iso year from before
        return Year(thisyear.value - 1)
    elseif weeknumber == 1 && thismonth.value == 12
        # If it is december, then its the next year
        return Year(thisyear.value + 1)
    else
        return thisyear
    end
end

"""
Return current ISO week date as defined in
https://en.wikipedia.org/wiki/ISO_week_date

The return type is a tuple of `Year`, `Week` and `Integer` (from 1 to 7)
"""
isoweekdate(dt::DateTime) = (isoyear(dt), week(dt), dayofweek(dt))

function quarter(days)

Review comment (suggestion):
```suggestion
Return the ISO year that contains `dt` (see https://en.wikipedia.org/wiki/ISO_week_date).
```

(I avoid the term "definition" because Wikipedia may be a bit too fluid to use explicitly as definition.)

Code after:
# https://en.wikipedia.org/wiki/Talk:ISO_week_date#Algorithms
const WEEK_INDEX = (15, 23, 3, 11)
function week(days)
    w = div(abs(days - 1), 7) % 20871
    c, w = divrem((w + (w >= 10435)), 5218)
    w = (w * 28 + WEEK_INDEX[c + 1]) % 1461
    return div(w, 28) + 1
end

"""
Return the number of ISO weeks in the given year (see https://en.wikipedia.org/wiki/ISO_week_date).

# Examples
```jldoctest
julia> weeksinyear(Year(2022))
52

julia> weeksinyear(Year(2020))
53
```
!!! compat "Julia 1.13"
    This function requires Julia 1.13 or later.
"""
function weeksinyear(y::Year)
    firstday = firstdayofyear(Date(y))
    lastday = lastdayofyear(Date(y))

    if dayofweek(firstday) == 4 || dayofweek(lastday) == 4
        return 53
    end
    return 52
end

"""
Return the ISO year that contains `dt` (see https://en.wikipedia.org/wiki/ISO_week_date).

# Examples
```jldoctest
julia> isoyear(Date(2022, 1, 1))
2021 years

julia> isoyear(Date(2021, 12, 31))
2021 years
```
!!! compat "Julia 1.13"
    This function requires Julia 1.13 or later.
"""
function isoyear(dt::DateTime)
    thisyear = Year(dt)
    thismonth = Month(dt)
    weeknumber = week(dt)
Repository: JuliaLang/julia
File: stdlib/Dates/src/accessors.jl (Julia)

Code before:
end

"""
Return current ISO year as defined in
https://en.wikipedia.org/wiki/ISO_week_date
"""
function isoyear(dt::DateTime)
    thisyear = Year(dt)
    thismonth = Month(dt)
    weeknumber = week(dt)
    if weeknumber >= 52 && thismonth.value == 1
        # If it is january, then its the iso year from before
        return Year(thisyear.value - 1)
    elseif weeknumber == 1 && thismonth.value == 12
        # If it is december, then its the next year
        return Year(thisyear.value + 1)
    else
        return thisyear
    end
end

"""
Return current ISO week date as defined in
https://en.wikipedia.org/wiki/ISO_week_date

The return type is a tuple of `Year`, `Week` and `Integer` (from 1 to 7)
"""
isoweekdate(dt::DateTime) = (isoyear(dt), week(dt), dayofweek(dt))

function quarter(days)
    m = month(days)
    return m < 4 ? 1 : m < 7 ? 2 : m < 10 ? 3 : 4
end


# Accessor functions
value(dt::TimeType) = dt.instant.periods.value
value(t::Time) = t.instant.value
days(dt::Date) = value(dt)
days(dt::DateTime) = fld(value(dt), 86400000)
year(dt::TimeType) = year(days(dt))
quarter(dt::TimeType) = quarter(days(dt))
month(dt::TimeType) = month(days(dt))
week(dt::TimeType) = week(days(dt))
day(dt::TimeType) = day(days(dt))
hour(dt::DateTime)   = mod(fld(value(dt), 3600000), 24)
minute(dt::DateTime) = mod(fld(value(dt), 60000), 60)
second(dt::DateTime) = mod(fld(value(dt), 1000), 60)
millisecond(dt::DateTime) = mod(value(dt), 1000)
hour(t::Time)   = mod(fld(value(t), 3600000000000), Int64(24))
minute(t::Time) = mod(fld(value(t), 60000000000), Int64(60))

Review comment (suggestion):
```suggestion
Return the ISO week date that corresponds to `dt` (see
https://en.wikipedia.org/wiki/ISO_week_date).

The return type is a tuple of `Year`, `Week` and `Integer` (from 1 to 7).
```

Code after:
    This function requires Julia 1.13 or later.
"""
function weeksinyear(y::Year)
    firstday = firstdayofyear(Date(y))
    lastday = lastdayofyear(Date(y))

    if dayofweek(firstday) == 4 || dayofweek(lastday) == 4
        return 53
    end
    return 52
end

"""
Return the ISO year that contains `dt` (see https://en.wikipedia.org/wiki/ISO_week_date).

# Examples
```jldoctest
julia> isoyear(Date(2022, 1, 1))
2021 years

julia> isoyear(Date(2021, 12, 31))
2021 years
```
!!! compat "Julia 1.13"
    This function requires Julia 1.13 or later.
"""
function isoyear(dt::DateTime)
    thisyear = Year(dt)
    thismonth = Month(dt)
    weeknumber = week(dt)
    if weeknumber >= 52 && thismonth.value == 1
        # If it is january, then its the iso year from before
        return Year(thisyear.value - 1)
    elseif weeknumber == 1 && thismonth.value == 12
        # If it is december, then its the next year
        return Year(thisyear.value + 1)
    else
        return thisyear
    end
end
isoyear(dt::Date) = isoyear(DateTime(dt))

"""
Return the ISO week date that corresponds to `dt` (see
https://en.wikipedia.org/wiki/ISO_week_date).

The return type is a tuple of `Year`, `Week` and `Int64` (from 1 to 7).

# Examples
```jldoctest
julia> isoweekdate(Date(2023, 03, 06))
Repository: JuliaLang/julia
File: stdlib/Dates/src/accessors.jl (Julia)

Code before:
end

# ISO year utils
# https://en.wikipedia.org/wiki/Talk:ISO_week_date#Algorithms
const WEEK_INDEX = (15, 23, 3, 11)
function week(days)
    w = div(abs(days - 1), 7) % 20871
    c, w = divrem((w + (w >= 10435)), 5218)
    w = (w * 28 + WEEK_INDEX[c + 1]) % 1461
    return div(w, 28) + 1
end

"""
Return the number of ISO weeks in the given year (see https://en.wikipedia.org/wiki/ISO_week_date).

# Examples
```jldoctest
julia> weeksinyear(Year(2022))
52

julia> weeksinyear(Year(2020))
53
"""
function weeksinyear(y::Year)
    firstday = firstdayofyear(Date(y))
    lastday = lastdayofyear(Date(y))

    if dayofweek(firstday) == 4 || dayofweek(lastday) == 4
        return 53
    end
    return 52
end

"""
Return the ISO year that contains `dt` (see https://en.wikipedia.org/wiki/ISO_week_date).

# Examples
```jldoctest
julia> isoyear(Date(2022, 1, 1))
Year(2021)

julia> isoyear(Date(2021, 12, 31))
Year(2021)
"""
function isoyear(dt::DateTime)
    thisyear = Year(dt)
    thismonth = Month(dt)
    weeknumber = week(dt)
    if weeknumber >= 52 && thismonth.value == 1
        # If it is january, then its the iso year from before
        return Year(thisyear.value - 1)

Review comment (suggestion):
```patch
+```
 """
```
close `jldoctest` block.

`isoyear` also needs this patch.


Code after:
end

# ISO year utils
# https://en.wikipedia.org/wiki/Talk:ISO_week_date#Algorithms
const WEEK_INDEX = (15, 23, 3, 11)
function week(days)
    w = div(abs(days - 1), 7) % 20871
    c, w = divrem((w + (w >= 10435)), 5218)
    w = (w * 28 + WEEK_INDEX[c + 1]) % 1461
    return div(w, 28) + 1
end

"""
Return the number of ISO weeks in the given year (see https://en.wikipedia.org/wiki/ISO_week_date).

# Examples
```jldoctest
julia> weeksinyear(Year(2022))
52

julia> weeksinyear(Year(2020))
53
```
!!! compat "Julia 1.13"
    This function requires Julia 1.13 or later.
"""
function weeksinyear(y::Year)
    firstday = firstdayofyear(Date(y))
    lastday = lastdayofyear(Date(y))

    if dayofweek(firstday) == 4 || dayofweek(lastday) == 4
        return 53
    end
    return 52
end

"""
Return the ISO year that contains `dt` (see https://en.wikipedia.org/wiki/ISO_week_date).

# Examples
```jldoctest
julia> isoyear(Date(2022, 1, 1))
2021 years

julia> isoyear(Date(2021, 12, 31))
2021 years
```
!!! compat "Julia 1.13"
    This function requires Julia 1.13 or later.
"""
function isoyear(dt::DateTime)
Repository: JuliaLang/julia
File: stdlib/Dates/src/accessors.jl (Julia)

Code before:
52

julia> weeksinyear(Year(2020))
53
```
"""
function weeksinyear(y::Year)
    firstday = firstdayofyear(Date(y))
    lastday = lastdayofyear(Date(y))

    if dayofweek(firstday) == 4 || dayofweek(lastday) == 4
        return 53
    end
    return 52
end

"""
Return the ISO year that contains `dt` (see https://en.wikipedia.org/wiki/ISO_week_date).

# Examples
```jldoctest
julia> isoyear(Date(2022, 1, 1))
Year(2021)

julia> isoyear(Date(2021, 12, 31))
Year(2021)
```
"""
function isoyear(dt::DateTime)
    thisyear = Year(dt)
    thismonth = Month(dt)
    weeknumber = week(dt)
    if weeknumber >= 52 && thismonth.value == 1
        # If it is january, then its the iso year from before
        return Year(thisyear.value - 1)
    elseif weeknumber == 1 && thismonth.value == 12
        # If it is december, then its the next year
        return Year(thisyear.value + 1)
    else
        return thisyear
    end
end
isoyear(dt::Date) = isoyear(DateTime(dt))

"""
Return the ISO week date that corresponds to `dt` (see
https://en.wikipedia.org/wiki/ISO_week_date).

The return type is a tuple of `Year`, `Week` and `Integer` (from 1 to 7).

# Examples

Review comment (suggestion):
```suggestion
julia> isoyear(Date(2022, 1, 1))
2021 years

julia> isoyear(Date(2021, 12, 31))
2021 years
```

Code after:
52

julia> weeksinyear(Year(2020))
53
```
!!! compat "Julia 1.13"
    This function requires Julia 1.13 or later.
"""
function weeksinyear(y::Year)
    firstday = firstdayofyear(Date(y))
    lastday = lastdayofyear(Date(y))

    if dayofweek(firstday) == 4 || dayofweek(lastday) == 4
        return 53
    end
    return 52
end

"""
Return the ISO year that contains `dt` (see https://en.wikipedia.org/wiki/ISO_week_date).

# Examples
```jldoctest
julia> isoyear(Date(2022, 1, 1))
2021 years

julia> isoyear(Date(2021, 12, 31))
2021 years
```
!!! compat "Julia 1.13"
    This function requires Julia 1.13 or later.
"""
function isoyear(dt::DateTime)
    thisyear = Year(dt)
    thismonth = Month(dt)
    weeknumber = week(dt)
    if weeknumber >= 52 && thismonth.value == 1
        # If it is january, then its the iso year from before
        return Year(thisyear.value - 1)
    elseif weeknumber == 1 && thismonth.value == 12
        # If it is december, then its the next year
        return Year(thisyear.value + 1)
    else
        return thisyear
    end
end
isoyear(dt::Date) = isoyear(DateTime(dt))

"""
Return the ISO week date that corresponds to `dt` (see
https://en.wikipedia.org/wiki/ISO_week_date).
Repository: JuliaLang/julia
File: stdlib/Dates/src/accessors.jl (Julia)

Code before:

julia> isoyear(Date(2021, 12, 31))
2021 years
```
"""
function isoyear(dt::DateTime)
    thisyear = Year(dt)
    thismonth = Month(dt)
    weeknumber = week(dt)
    if weeknumber >= 52 && thismonth.value == 1
        # If it is january, then its the iso year from before
        return Year(thisyear.value - 1)
    elseif weeknumber == 1 && thismonth.value == 12
        # If it is december, then its the next year
        return Year(thisyear.value + 1)
    else
        return thisyear
    end
end
isoyear(dt::Date) = isoyear(DateTime(dt))

"""
Return the ISO week date that corresponds to `dt` (see
https://en.wikipedia.org/wiki/ISO_week_date).

The return type is a tuple of `Year`, `Week` and `Integer` (from 1 to 7).

# Examples
```jldoctest
julia> isoweekdate(Date(2023, 03, 06))
(2023, 10, 1)

julia> isoweekdate(Date(2023, 01, 01))
(2022, 52, 7)
```
"""
isoweekdate(dt::DateTime) = (isoyear(dt).value, week(dt), dayofweek(dt))
isoweekdate(dt::Date) = isoweekdate(DateTime(dt))

function quarter(days)
    m = month(days)
    return m < 4 ? 1 : m < 7 ? 2 : m < 10 ? 3 : 4
end


# Accessor functions
value(dt::TimeType) = dt.instant.periods.value
value(t::Time) = t.instant.value
days(dt::Date) = value(dt)
days(dt::DateTime) = fld(value(dt), 86400000)
year(dt::TimeType) = year(days(dt))

Review comment (refactor):
```suggestion
The return type is a tuple of `Year`, `Week` and `Int64` (from 1 to 7).
```

(`Int64` is the actual type returned while `Integer` is an abstract type).

Code after:
julia> isoyear(Date(2022, 1, 1))
2021 years

julia> isoyear(Date(2021, 12, 31))
2021 years
```
!!! compat "Julia 1.13"
    This function requires Julia 1.13 or later.
"""
function isoyear(dt::DateTime)
    thisyear = Year(dt)
    thismonth = Month(dt)
    weeknumber = week(dt)
    if weeknumber >= 52 && thismonth.value == 1
        # If it is january, then its the iso year from before
        return Year(thisyear.value - 1)
    elseif weeknumber == 1 && thismonth.value == 12
        # If it is december, then its the next year
        return Year(thisyear.value + 1)
    else
        return thisyear
    end
end
isoyear(dt::Date) = isoyear(DateTime(dt))

"""
Return the ISO week date that corresponds to `dt` (see
https://en.wikipedia.org/wiki/ISO_week_date).

The return type is a tuple of `Year`, `Week` and `Int64` (from 1 to 7).

# Examples
```jldoctest
julia> isoweekdate(Date(2023, 03, 06))
(2023, 10, 1)

julia> isoweekdate(Date(2023, 01, 01))
(2022, 52, 7)
```
!!! compat "Julia 1.13"
    This function requires Julia 1.13 or later.
"""
isoweekdate(dt::DateTime) = (isoyear(dt).value, week(dt), dayofweek(dt))
isoweekdate(dt::Date) = isoweekdate(DateTime(dt))

function quarter(days)
    m = month(days)
    return m < 4 ? 1 : m < 7 ? 2 : m < 10 ? 3 : 4
end
Repository: JuliaLang/julia
File: base/intfuncs.jl (Julia)

Code before:
const powers_of_ten = [
    0x0000000000000001, 0x000000000000000a, 0x0000000000000064, 0x00000000000003e8,
    0x0000000000002710, 0x00000000000186a0, 0x00000000000f4240, 0x0000000000989680,
    0x0000000005f5e100, 0x000000003b9aca00, 0x00000002540be400, 0x000000174876e800,
    0x000000e8d4a51000, 0x000009184e72a000, 0x00005af3107a4000, 0x00038d7ea4c68000,
    0x002386f26fc10000, 0x016345785d8a0000, 0x0de0b6b3a7640000, 0x8ac7230489e80000,
]
function bit_ndigits0z(x::Base.BitUnsigned64)
    lz = top_set_bit(x)
    nd = (1233*lz)>>12+1
    nd -= x < powers_of_ten[nd]
end
function bit_ndigits0z(x::UInt128)
    n = 0
    while x > 0x8ac7230489e80000
        x = div(x,0x8ac7230489e80000)
        n += 19
    end
    return n + ndigits0z(UInt64(x))
end

ndigits0z(x::BitSigned) = bit_ndigits0z(unsigned(abs(x)))
ndigits0z(x::BitUnsigned) = bit_ndigits0z(x)
ndigits0z(x::Integer) = ndigits0zpb(x, 10)

## ndigits with specified base ##

# The suffix "nb" stands for "negative base"
function ndigits0znb(x::Integer, b::Integer)
    d = 0
    if x isa Unsigned
        d += (x != 0)::Bool
        x = -signed(fld(x, -b))
    end
    # precondition: b < -1 && !(typeof(x) <: Unsigned)
    while x != 0
        x = cld(x,b)
        d += 1
    end
    return d
end

# do first division before conversion with signed here, which can otherwise overflow
ndigits0znb(x::Bool, b::Integer) = x % Int

# The suffix "pb" stands for "positive base"
function ndigits0zpb(x::Integer, b::Integer)
    # precondition: b > 1
    x == 0 && return 0
    b = Int(b)
    x = abs(x)

Review comment (suggestion):
If we guarantee the error (having automatic type widening in Base is a non-starter, as far as I'm aware) this throwing behavior should be documented & tested. 

Code after:
julia> nextpow(2, 7)
8

julia> nextpow(2, 9)
16

julia> nextpow(5, 20)
25

julia> nextpow(4, 16)
16
```
"""
function nextpow(a::Real, x::Real)
    x <= 0 && throw(DomainError(x, "`x` must be positive."))
    # Special case fast path for x::Integer, a == 2.
    # This is a very common case. Constant prop will make sure that a call site
    # specified as `nextpow(2, x)` will get this special case inlined.
    a == 2 && isa(x, Integer) && return _nextpow2(x)
    a <= 1 && throw(DomainError(a, "`a` must be greater than 1."))
    x <= 1 && return one(a)
    n = ceil(Integer,log(a, x))
    # round-off error of log can go either direction, so need some checks
    p = a^(n-1)
    hastypemax(typeof(p)) && x > typemax(p) &&
        throw(DomainError(x,"argument is beyond the range of type of the base"))
    p >= x && return p
    wp = a^n
    wp > p || throw(OverflowError("result is beyond the range of type of the base"))
    wp >= x && return wp
    wwp = a^(n+1)
    wwp > wp || throw(OverflowError("result is beyond the range of type of the base"))
    return wwp
end

"""
    prevpow(a, x)

The largest `a^n` not greater than `x`, where `n` is a non-negative integer.
`a` must be greater than 1, and `x` must not be less than 1.

See also [`nextpow`](@ref), [`isqrt`](@ref).

# Examples
```jldoctest
julia> prevpow(2, 7)
4

julia> prevpow(2, 9)
8
Repository: JuliaLang/julia
File: base/c.jl (Julia)

Code before:
with a Julia variable named `s`. See also `ccall`.

Varargs are supported with the following convention:

    @ccall printf("%s = %d"::Cstring ; "foo"::Cstring, foo::Cint)::Cint

The semicolon is used to separate required arguments (of which there
must be at least one) from variadic arguments.

Example using an external library:

    # C signature of g_uri_escape_string:
    # char *g_uri_escape_string(const char *unescaped, const char *reserved_chars_allowed, gboolean allow_utf8);

    const glib = "libglib-2.0"
    @ccall glib.g_uri_escape_string(my_uri::Cstring, ":/"::Cstring, true::Cint)::Cstring

The string literal could also be used directly before the function
name, if desired `"libglib-2.0".g_uri_escape_string(...`

It's possible to declare the ccall as `gc_safe` by using the `gc_safe = true` option:
    @ccall gc_safe=true strlen(s::Cstring)::Csize_t
This allows the garbage collector to run concurrently with the ccall, which can be useful whenever
the ccall may block outside of julia.
WARNING: This option should be used with caution, as it can lead to undefined behavior if the ccall
calls back into the julia runtime. (@cfunction/@ccallables are safe however)
"""
macro ccall(exprs...)
    return ccall_macro_lower((:ccall), ccall_macro_parse(exprs)...)
end

macro ccall_effects(effects::UInt16, expr)
    return ccall_macro_lower((:ccall, effects), ccall_macro_parse(expr)...)
end


Review comment (suggestion):
```suggestion
calls back into the julia runtime. (`@cfunction`/`@ccallables` are safe however)
```

Code after:

Varargs are supported with the following convention:

    @ccall printf("%s = %d"::Cstring ; "foo"::Cstring, foo::Cint)::Cint

The semicolon is used to separate required arguments (of which there
must be at least one) from variadic arguments.

Example using an external library:

    # C signature of g_uri_escape_string:
    # char *g_uri_escape_string(const char *unescaped, const char *reserved_chars_allowed, gboolean allow_utf8);

    const glib = "libglib-2.0"
    @ccall glib.g_uri_escape_string(my_uri::Cstring, ":/"::Cstring, true::Cint)::Cstring

The string literal could also be used directly before the function
name, if desired `"libglib-2.0".g_uri_escape_string(...`

It's possible to declare the ccall as `gc_safe` by using the `gc_safe = true` option:
    @ccall gc_safe=true strlen(s::Cstring)::Csize_t
This allows the garbage collector to run concurrently with the ccall, which can be useful whenever
the `ccall` may block outside of julia.
WARNING: This option should be used with caution, as it can lead to undefined behavior if the ccall
calls back into the julia runtime. (`@cfunction`/`@ccallables` are safe however)
"""
macro ccall(exprs...)
    return ccall_macro_lower((:ccall), ccall_macro_parse(exprs)...)
end

macro ccall_effects(effects::UInt16, expr)
    return ccall_macro_lower((:ccall, effects), ccall_macro_parse(expr)...)
end