Skip to content

Subarray of an array with undefined members. #3868

@amitmurthy

Description

@amitmurthy

It ought to be possible to get a sub array of an array with undefined members - for cases where you want to allocate an array once and then use different functions to populate different parts of the array.

foo = cell(10)
init1(foo[1:4])
init2(foo[5:end])

Currently

julia> foo=cell(3)
3-element Any Array:
 #undef
 #undef
 #undef

julia> bar=foo[2:end]
ERROR: access to undefined reference
 in unsafe_copy! at array.jl:51
 in copy! at array.jl:61
 in getindex at array.jl:295

I understand why the above is happening but is it possible just to leave the same fields as undefined in the subarray?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions