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

Rename get_bigfloat_precision, set_bigfloat_precision and with_bigfloat_precision #13225

Closed
dpsanders opened this issue Sep 19, 2015 · 12 comments

Comments

@dpsanders
Copy link
Contributor

The function names get_bigfloat_precision, set_bigfloat_precision and with_bigfloat_precision are cumbersome and un-Julian.
I suggest changing these as follows:

  • get_bigfloat_precision() -> precision(BigFloat)
  • set_bigfloat_precision(n) -> set_precision!(BigFloat, n) or just set_precision!(n) or precision!(n)
  • with_bigfloat_precision(n) -> with_precision(n)

Cc. @simonbyrne @stevengj @jiahao

@ScottPJones
Copy link
Contributor

Please! Of course, this also works for decimal float, maybe unums.

@dpsanders
Copy link
Contributor Author

@ScottPJones Yes, good point.

@dpsanders dpsanders changed the title Change get_bigfloat_precision and set_bigfloat_precision Rename get_bigfloat_precision, set_bigfloat_precision and with_bigfloat_precision Sep 19, 2015
@ScottPJones
Copy link
Contributor

You might need with_precision(T, n) as well as with_precision(n), to be able to handle setting precision for BigFloat, decimal floats, unums [when we get them]) separately, same as set_precision!

@tkelman
Copy link
Contributor

tkelman commented Sep 19, 2015

probably drop the underscores, readable enough as setprecision! and withprecision IMO

@dpsanders
Copy link
Contributor Author

@tkelman I partially agree, but currently set_rounding is written with an underscore (but without a !...)

set_bigfloat_precision, set_rounding and set_zero_subnormals are the only so-named functions in Base. Perhaps it's time to remove the set_ and just use !?

@ScottPJones
Copy link
Contributor

The underscores do make it easier to read, there have even been studies on that (comparing camel case to separation with underscores to no separation).
I think having a set_XXX(...) is easier to read if you have a XXX(...), rather than XXX!(...).
Also, I'm not even sure it should have the !, because it is not modifying any of the arguments, it is modifying some state.

@StefanKarpinski
Copy link
Sponsor Member

Studies or no, we don't use underscores on Base functions.

@ScottPJones
Copy link
Contributor

set_rounding???

@ScottPJones
Copy link
Contributor

I honestly have a hard time believing you said that.

A_ldiv_B!, A_ldiv_Bc, A_ldiv_Bt, A_mul_B!, A_mul_Bc, A_mul_Bc!, A_mul_Bt, A_mul_Bt!, A_rdiv_Bc, A_rdiv_Bt,
Ac_ldiv_B, Ac_ldiv_Bc, Ac_mul_B, Ac_mul_B!, Ac_mul_Bc, Ac_mul_Bc!, Ac_rdiv_B, Ac_rdiv_Bc, At_ldiv_B, At_ldiv_Bt,
At_mul_B, At_mul_B!, At_mul_Bt, At_mul_Bt!, At_rdiv_B, At_rdiv_Bt,
count_ones, count_zeros, leading_ones, leading_zeros, trailing_ones, trailing_zeros,
unsafe_trunc, broadcast!_function, broadcast_function, broadcast_getindex, broadcast_setindex!,
cumsum_kbn, promote_shape, sum_kbn, blas_set_num_threads, escape_string, is_assigned_char, normalize_string,
print_escaped, print_joined, print_shortest, print_unescaped, print_with_color, unescape_string,
get_bigfloat_precision, set_bigfloat_precision, with_bigfloat_precision, get_rounding, set_rounding, with_rounding,
get_zero_subnormals, set_zero_subnormals,
plan_bfft!, plan_bfft, plan_brfft, plan_dct!, plan_dct, plan_fft!, plan_fft, plan_idct!, plan_idct, plan_ifft!,
plan_ifft, plan_irfft, plan_rfft, object_id, current_task, task_local_storage, time_ns, catch_backtrace,
promote_rule, promote_type, current_module, code_typed, code_warntype, code_lowered, code_llvm, code_native, module_name,
module_parent, __precompile__, include_string, include_dependency, gc_enable, nb_available, poll_fd, poll_file,
redirect_stderr, redirect_stdin, redirect_stdout, takebuf_array, takebuf_string, watch_file, init_worker, remotecall_fetch,
remotecall_wait, process_exited, process_running, disable_sigint, pointer_from_objref, pointer_to_array, pointer_to_string,
reenable_sigint, unsafe_copy!, unsafe_load, unsafe_pointer_to_objref, unsafe_store!

113 functions that are exported, many many more that are not exported (but since there is no way of telling whether they are "private" or not, they very well may be used outside of Base), and that also didn't count macros with _.

@dpsanders
Copy link
Contributor Author

My takeaway from this discussion is:

  • no ! on setprecision
  • divided on underscores (I presonally tend to find readability increases with relevant underscores)
  • replace with_precision with setprecision
  • do the same for with_rounding and set_rounding.

I'll implement these in the PR, with no underscores for now.

@StefanKarpinski
Copy link
Sponsor Member

@ScottPJones: we would like to get rid of or rename all of those. Underscores are a sign of an old, crappy or inadequately designed API. By Julia 1.0 we should have eliminated most of them. In particular, we should not be adding more of them.

@simonbyrne
Copy link
Contributor

Okay, I'm fine with this. Would you mind rebasing into one commit?

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

5 participants