I wanted to get some discussion going on what helper tools people want / need to make coding, especially when interactively analyzing data, more enjoyable and efficient. I believe that Julia with its introspective abilities can do more in this regard.
For example, I like propertynames
because authors can enhance what dot completion can do for the user. But there are many other things where more could be suggested for tab completion etc. I know this is often a question for packages like Juno but at the same time, maybe it’s helpful to offer simple packages that help authors include this functionality themselves instead of relying on third parties. Maybe a lot of these things can live in something like SuggestionsBase or TabCompletionBase etc.
In RStudio for example, when operating on dataframes many functions accept column names that look like variables. These variables already get suggested for tab completion while typing the function, once the dataframe argument is specified. Of course, Julia doesn’t allow for variable names to be interpreted only inside functions like in R, but the same would work with symbols for column names.
This could be implemented by specifying a function that filters the workspace for suitable objects and displays their variable names. I know that this is already done to some degree, but it is not implemented by package authors like with propertynames
.
Imagine if instead the author could specify with simple functions with what rules suitable variables can be determined, and something like Juno would only call this function. Example:
SuggestionsBase.suggest(f::typeof(plotdataframefunc), df::DataFrame, arg::Val{2})
# arg 2 of this function is one of the column names if arg 1 is a dataframe
names(df)
end
SuggestionsBase.suggest(f::typeof(plotdataframefunc), arg::Val{3})
# arg 3 of this function is one of these symbols for plotting, this does not need a dataframe in the first position for completion
[:cross, :square, :circle]
end
What do you think about this idea, or are there others that you think would work better? What other functionality would be useful? Basically I’m all for suggesting and pre-filtering as much as possible if we know already what people are going to do in 99% of cases. Especially if there’s a known list of allowed parameters, like in the second example.