DataArrays.jl
DataArrays.jl copied to clipboard
Minimal constructors
Why discussing the recent changes to DA constructors, @simonster made a suggestion that I really like that would have us remove a constructor that isn't strictly.
I'd like to propose the following design principle:
- We only offer two constructors for DA's and PDA's:
- Construction using the implementation details
- Construction using an empty DA/PDA of a specific type and size.
- For creating objects, one either uses:
- Literals written using
@dataor@pdata - Explicit conversions.
- Literals written using
Does this sound right to you, @simonster?
Not sure how I feel about this. Being able to create a DataArray from an array using the short DataArray(a) rather than the cumbersome convert(DataArray, a) is nice, just like there is sparse(a).
Anyway I don't care about other fancy constructors.
Let's just add data and pdata functions for that use case.
Sounds good to me. It would also be good if @data([a]) did conversion to a DataArray, as it does conversion to an Array in Base (but see JuliaLang/julia#3737). I'll see if I can make that happen.
Shouldn't be too hard, just special case the macros to rewrite calls to the new data and pdata functions instead of calling the constructors.
I added data and pdata in ae7d8203a1089b2cf05494c6cc209a6043f51b86
Good!