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

Conversion from array #38

Closed
cstjean opened this issue Nov 7, 2018 · 2 comments
Closed

Conversion from array #38

cstjean opened this issue Nov 7, 2018 · 2 comments

Comments

@cstjean
Copy link
Collaborator

cstjean commented Nov 7, 2018

What would you say to supporting convert(Fill, [2.0,2.0,2.0]), and throwing an error if it's not uniformly the same value?

@cstjean
Copy link
Collaborator Author

cstjean commented Nov 7, 2018

I can see an issue with empty vectors: convert(Fill, String[]). We can use Fill("any string", 0). But how do we get an instance of some arbitrary type T, to put in the value field? one(T)/zero(T)/... might not be defined.

Solution 1: use #undef, which we could do if the inner constructor could call new(axes=axes), but new doesn't do that yet. So we'd have to shuffle the field order so that value can be #under, which is unappealing.

Solution 2: have a function any_value(::Type{T}) where T<:Number = oneunit(T), that gives us that value. It works, but it's ugly.

Solution 3: throw an error on empty vectors.

Do you see anything else?

@dlfivefifty
Copy link
Member

Just throw an error I think. Though I’m not sure what the use case for this is.

Note you should also add variants like convert(AbstractFill{T} , v)

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

No branches or pull requests

2 participants