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
Smarter REPL completions II #52661
Comments
The reason this doesn't work is that in Julia, functions are not accessed using the dot syntax. So, you can only get the fields this way. To get methods that apply to an object, you can write |
Understood, however the current approach seems highly unergonomic, unless I'm missing how to not search the whole Terminal display history for 'startswith' if one wants to see the parallel of y.startsw[TAB] Of cause upon selection the function would need to be prefixed: Unless julia adopted the honorable nim approach of treating a.b() and b(a) as equivalents. |
That'd be a rather large design change to the Julia language, when the language has already stabilized. That's not going to happen. However, you're right that there is no way to autocomplete the julia> startsw?(y<TAB>
startswith(s)
startswith(s::AbstractString, r::Regex)
[etc.] |
It's a bit of a problem how many apply, even just for the string type. And apply, but not always, as with BigFloat.
Yes, ideally, somehow, and I checked now for the first time with ?(my_object. and the list is huge with what e.g. applies...: HTML(content::T) where T @ Base.Docs docs/utils.jl:30 but also:
and many more false positives (am I seeing the full list of functions?). I suppose just a bug that could be easily fixed (or I'm "using it wrong"?).
I'm not sure that's a good idea, promoting two styles, but BECAUSE:
I see no issue with allowing the former a.b for completion purposes, and whey you choose it changes to the latter, also teaching people coming from OOP languages. FYI. You CAN also do e.g. for yet an alternative syntax: julia> x = y |> l # looking up length or e.g. lstrip, I get a reasonably small list this way. It's not ideal, I'm not sure why I get e.g. log, log10, log1p, log2, probably the type totally disregarded (only looking at if one argument). Another improvement could be case-insensitive search, to get e.g. LazyString, thaugh less useful seeing e.g. LinRange that would never apply, for strings. It's understandable that BigFloat and BigInt are completed for strings, since the type matches, they for most contents it does not... I don't really expect completion to match type and content, though it might be awesome... Should not match: possibly, except drop at least all deprecated, and show at least as one entry?: BigFloat(x::AbstractString, r::RoundingMode; precision) @ Base.MPFR mpfr.jl:310 |
For your example I would yes, want to get all startswith variants (but only when that specific), startswith(s) isn't one of them: startswith(s::AbstractString, r::Regex) @ Base regex.jl:320 But when competing e.g. st only get startswith, stat, string, strip, not all variants of each with type info. |
The |> trick works great, thanks.
Now the only thing left would be to adopt this for the dot
Exactly! |
Ok, so let's make a list of things that can be improved:
Anything else? |
Intention: see all properties / fields / functions applicable to object :
julia> y="hello"
julia> y.[TAB]
Result: No completions
Expected: size, length, substring, reverse, ...
PS: The following already works in Version 1.10.0 :
The text was updated successfully, but these errors were encountered: