3 ms·
My personal experience is that it would be great if REPL can provide some quick references for APIs, etc.
by chaosprint 4y ago
My personal experience is that it would be great if REPL can provide some quick references for APIs, etc.
- capableweb 4y ago> (A good REPL) gives you access to your whole project code. You should be able to call any piece of code written in your project of its dependencies. As an execution platform, the REPL should reproduce the conditions of running code in production as much as possible. Then, some languages (like Clojure) have global functions like `doc` or `apropos` that helps you write code. => (doc map) ------------------------- clojure.core/map ([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]) Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments. => (apropos #".+?reduce") ------------------------- (clojure.core/areduce clojure.core/ensure-reduced clojure.core/unreduced ...) So when you write Clojure code with a REPL, you hardly need anything else but a REPL + text editor that can connect to said REPL.
- agentwiggles 4y agoThe docs in the Elixir REPL are such a pleasure to use. Tab completing a function will show a list of possible matches, and then you can type `h function_name` to see the doc for that function. It's incredibly useful, partially because the standard library is well organized. For example, maybe you need some string manipulation function, but you're not sure what it's called. You'd type `h String.` and then hit tab. Now all the functions of that module are listed. Ah, String.graphemes looks promising - so you finish your line `h String.Graphemes` and skim the doc. Now, to make sure you understand, you might type `String.graphemes("foo")` and then see the result is what you want. I almost never have to Google for an answer when writing Elixir (at least for simple stuff) because the REPL is so robust as a doc lookup tool. My only wish is that the vscode extension had some features around sending buffer code to the REPL like SLIME or other Lispy editor plugins. You can reload code, but it's a little more manual than I'd like.