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

better access to allowDownsize #18

Closed
wilzbach opened this issue Mar 5, 2016 · 9 comments
Closed

better access to allowDownsize #18

wilzbach opened this issue Mar 5, 2016 · 9 comments
Labels

Comments

@wilzbach
Copy link
Member

wilzbach commented Mar 5, 2016

It seems that this that the default flag for allowDownsize has been recently changed - (at least for the latest version in phobos).

This makes sense, but we should have a handy access to the flag, this is annoying!

iota(10).sliced!(Yes.replaceArrayWithPointer, Yes.allowDownsize)(4);
@9il
Copy link
Member

9il commented Mar 5, 2016

You can make an alias alias mysliced = sliced!(Yes.replaceArrayWithPointer, Yes.allowDownsize);

@wilzbach
Copy link
Member Author

wilzbach commented Mar 5, 2016

Yeah, but my point was that this is a rather common pattern and the alias should be within mir ;-)

@9il
Copy link
Member

9il commented Mar 5, 2016

The main problem is good function name)

@wilzbach
Copy link
Member Author

wilzbach commented Mar 5, 2016

downsliced?

@9il
Copy link
Member

9il commented Mar 5, 2016

downsliced?

@John-Colvin what do you think?

@greenify John is native English speaker.

@John-Colvin
Copy link
Contributor

I'm not convinced that it's necessary/beneficial to have an alias at all.

@greenify what important use-cases do you have for the Yes.allowDownsize semantics? I don't really see the value in it, but perhaps I'm not being imaginative enough

@wilzbach
Copy link
Member Author

wilzbach commented Mar 5, 2016

what important use-cases do you have for the Yes.allowDownsize semantics? I don't really see the value in it, but perhaps I'm not being imaginative enough

it happened quite often to me in NumPy and my point was more that I have to select the option for replaceArrayWithPointer even though in most cases I don't want to bother with this option.

I can still repeat the example given above:

iota(10).sliced!(Yes.replaceArrayWithPointer, Yes.allowDownsize)(4);

or let's say I initially created lots of random numbers and want to seed my arrays:

int[] randoms = new int[1000];
// do sth. with them
randoms.downsize(3,  3);
randoms.downsize!2(3,  3, 9); //sample again from same array with shift

It's hard to come up with a really "good" usecase, because one can always argue: hey that's your fault.

@wilzbach
Copy link
Member Author

wilzbach commented Mar 5, 2016

Update: If I look through the current documentation at Phobos I see this pattern to have a larger input source quite often, that's btw why I was a bit surprised when I realized that you might have changed the defaults.

So all those definitions fail and need to replaced with the bulky thing from above:

1000.iota.sliced(3, 4, 5)
auto slice = new int[1000].sliced(5, 13);
// etc.

@9il 9il added the wontfix label Mar 25, 2016
@wilzbach
Copy link
Member Author

Closing this for now - though we shouldn't forget when we create new APIs that such template flags are dependent on the order and access to the last ones might be inconvenient ;-)

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

No branches or pull requests

3 participants