Skip to content

Conversation

aplavin
Copy link
Member

@aplavin aplavin commented Nov 24, 2022

Fixes #247 - added tests would fail before.
Thanks @jishnub for help in understanding that issue.

I think the updated code is not only more type-stable, but also cleaner in general.

@aplavin aplavin mentioned this pull request Nov 24, 2022
@aplavin
Copy link
Member Author

aplavin commented Nov 28, 2022

bump...
@piever

f = key -> $op((getproperty(t, key) for t in args)...; kwargs...)
T = mapreduce(eltype, promote_type, args)
StructArray{T}(map(f, propertynames(args[1])))
StructArray{T}(map((oargs...) -> $op(oargs...; kwargs...), map(components, args)...))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the change (iterating on a Tuple as it was done before seems incorrect).

This is a little bit hard to read though. Could it be split over several lines giving meaningful names to the variables? Maybe something like

for op in [:cat, :hcat, :vcat]
    f = Symbol(:curried, op) # or another descriptive name
    @eval begin
        function Base.$op(args::StructArray...; kwargs...)
            $f(vs...) = $op(vs...; kwargs...)

From what I understand named functions are a bit better than anonymous functions here for the purpose of error messages (if the anonymous function throws, the stack trace is a bit harder to read).

@piever
Copy link
Collaborator

piever commented Nov 30, 2022

Left a small comment, but I agree with the change overall. Note that this should also be rebased to include the piracy fix in #254

@jishnub
Copy link
Member

jishnub commented Dec 8, 2022

Gentle bump, would be good to have this included

@piever
Copy link
Collaborator

piever commented Dec 10, 2022

Sure, merged and tagged in #258

@piever piever closed this Dec 10, 2022
@aplavin
Copy link
Member Author

aplavin commented Dec 11, 2022

Great, thanks! I'm still travelling, didn't have time to update this PR.

@aplavin aplavin deleted the typestab branch January 11, 2023 14:31
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.

vcat is type-unstable

3 participants