Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NamedTuple #19

Merged
merged 1 commit into from
Apr 5, 2023
Merged

Support NamedTuple #19

merged 1 commit into from
Apr 5, 2023

Conversation

KnutAM
Copy link
Contributor

@KnutAM KnutAM commented Apr 4, 2023

Thanks for this nice package!
Not sure if this is the correct way, and I also don't know how to test that it actually unrolled, but it seems to work:

master

using Unrolled

@unroll function my_sum(seq)
    # More on why we need @unroll twice later.
    total = zero(eltype(seq))
    @unroll for x in seq
        total += x
    end
    return total
end

@code_unrolled my_sum((a=1, b=2))
quote
    #= REPL[3]:1 =#
    #= REPL[3]:3 =#
    total = zero(eltype(seq))
    #= REPL[3]:4 =#
    for x = seq
        #= C:\Users\meyer\.julia\packages\Unrolled\nMVH3\src\Unrolled.jl:110 =#
        total += x
        #= C:\Users\meyer\.julia\packages\Unrolled\nMVH3\src\Unrolled.jl:110 =#
    end
    #= REPL[3]:7 =#
    return total
end

PR

@code_unrolled my_sum((a=1, b=2))
quote
    #= REPL[3]:1 =#
    #= REPL[3]:3 =#
    total = zero(eltype(seq))
    #= REPL[3]:4 =#
    begin
        #= C:\Users\meyer\.julia\packages\Unrolled\nMVH3\src\Unrolled.jl:47 =#
        let x = seq[1]
            #= C:\Users\meyer\.julia\packages\Unrolled\nMVH3\src\Unrolled.jl:47 =#
            total += x
        end
        let x = seq[2]
            #= C:\Users\meyer\.julia\packages\Unrolled\nMVH3\src\Unrolled.jl:47 =#
            total += x
        end
        #= C:\Users\meyer\.julia\packages\Unrolled\nMVH3\src\Unrolled.jl:48 =#
        nothing
    end
    #= REPL[3]:7 =#
    return total
end

@cstjean
Copy link
Owner

cstjean commented Apr 5, 2023

Glad that it's this simple! Yeah, I do believe it should just work. Thanks!

@coveralls
Copy link

Pull Request Test Coverage Report for Build 4611325673

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.0%) to 66.129%

Totals Coverage Status
Change from base Build 2965983145: 0.0%
Covered Lines: 82
Relevant Lines: 124

💛 - Coveralls

@cstjean cstjean merged commit 3a6782c into cstjean:master Apr 5, 2023
@KnutAM KnutAM deleted the kam/NamedTuple branch April 5, 2023 21:06
@KnutAM
Copy link
Contributor Author

KnutAM commented Apr 5, 2023

@cstjean : Can a patch release be made with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants