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

Repl autocompletion for composite type fields #1773

Closed
binarybana opened this issue Dec 16, 2012 · 8 comments
Closed

Repl autocompletion for composite type fields #1773

binarybana opened this issue Dec 16, 2012 · 8 comments
Labels
REPL Julia's REPL (Read Eval Print Loop)
Milestone

Comments

@binarybana
Copy link
Contributor

julia> z = match(r"a", "apa")
RegexMatch("a")

julia> z.<tab><tab>

I know I can find the names of a composite type with typeof(z).names but I'd rather the repl do it for me and sprinkle some of its automagic-super-duper-wonderful-tab-completion-dust all over that tuple. :)

@johnmyleswhite
Copy link
Member

I also like this idea a lot. As a first step, I'd add a fields() function that does the names retrieval for you:

function fields(v)
  if typeof(v) == CompositeKind
    return v.names
  elseif typeof(typeof(v)) == CompositeKind
    return typeof(v).names
  else
    error("Cannot call fields() on a non-composite type")
  end
end

I've been using that specific hack for a while now.

julia> fields(1)
Cannot call fields() on a non-composite type
 in fields at none:7

julia> fields(OUTPUT_STREAM)
(:ios,:name)

julia> fields(IOStream)
(:ios,:name)

@pao
Copy link
Member

pao commented Dec 16, 2012

MATLAB calls this method fieldnames(), and I recall I got shot down when I tried to add it months ago, though it didn't chain the lookup as this does.

@toivoh
Copy link
Contributor

toivoh commented Dec 16, 2012

If it is added, it should probably filter out those names that are symbol("")?

@johnmyleswhite
Copy link
Member

Hmm. I think fieldnames() would be great.

@JeffBezanson
Copy link
Member

We have names(module); we could add this to that.

@pao
Copy link
Member

pao commented Dec 17, 2012

This would be a natural extension to names().

@StefanKarpinski
Copy link
Member

+1

@diegozea
Copy link
Contributor

+1
I was looking for the same functionality of REPL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

No branches or pull requests

7 participants