# How to use the REPL to speed up modular development by dynamically replacing function definitions

**URL:** https://discourse.julialang.org/t/how-to-use-the-repl-to-speed-up-modular-development-by-dynamically-replacing-function-definitions/122326
**Category:** New to Julia
**Tags:** question
**Created:** [November 6, 2024, 10:41am UTC](https://discourse.julialang.org/t/how-to-use-the-repl-to-speed-up-modular-development-by-dynamically-replacing-function-definitions/122326 "2024-11-06T10:41:08Z")
**Posts on this page:** 7
**Page:** 2

<div class="post-metadata">

### Author: ![world-peace](https://avatars.discourse-cdn.com/v4/letter/w/9f8e36/32.png) [@world-peace](https://discourse.julialang.org/u/world-peace)
#### Post date: [November 9, 2024, 4:05pm UTC](https://discourse.julialang.org/t/how-to-use-the-repl-to-speed-up-modular-development-by-dynamically-replacing-function-definitions/122326/21 "2024-11-09T16:05:31Z")

</div>

> [@Benny](#):
>
> REPL and a file editor can’t be open at the same time on the server

Yes, that’s correct.

> [@Benny](#):
>
> get or generate local data?

In theory yes. Actually I intend to do one better than this. Build an entire “UAT system” (aka another server, just not the same one as the prod data lives on).

Since only the statistical properties of the data are relevant, it should be easy to generate some MC data which isn’t sensitive in the same way as the prod data is.

But again, this is not a quick job. It will probably take longer than anyone might anticipate because of the validation which will need to be done on the MC data samples.

When I say _should be easy_ that actually depends a lot on the method used to simulate the data. We might not be permitted to do the most and straightforward simple thing.

---

<div class="post-metadata">

### Author: ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)
#### Post date: [November 9, 2024, 4:24pm UTC](https://discourse.julialang.org/t/how-to-use-the-repl-to-speed-up-modular-development-by-dynamically-replacing-function-definitions/122326/22 "2024-11-09T16:24:37Z")

</div>

This package was registered a few days ago: [GitHub - vdayanand/Txtar.jl: package to handle text archives](https://github.com/vdayanand/Txtar.jl)

That looks like it might be helpful with transferring a whole bunch of files at the same time via pasting via `vim`.

So, develop locally, when you want to deploy, package up all your code into a `txtar` file, and copy the content of that file to your clipboard. On the remote, have a REPL open (with `Revise`), use `edit` in the REPL to open `vim`, paste in the `txtar` data, “untar” it after returning to the REPL, let Revise automatically reload your code.

---

<div class="post-metadata">

### Author: ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)
#### Post date: [November 10, 2024, 12:51am UTC](https://discourse.julialang.org/t/how-to-use-the-repl-to-speed-up-modular-development-by-dynamically-replacing-function-definitions/122326/23 "2024-11-10T00:51:51Z")

</div>

> [@goerz](#):
>
> On the remote, have a REPL open (with `Revise`), use `edit` in the REPL to open `vim`

OP is saying the REPL and `vim` can’t be open at the same time on the server. Though I am curious what happens when `edit` is attempted. Does `vim` fail to open entirely? Does `vim` open but it’s impossible to switch to it from an active REPL?

If resorting to copying whole files instead of small edits and saves (which isn’t scalable but one problem at a time), then it’s possible to over-`write` a whole file with a multiline `String` with pasted text before `include`. Could skip a step with `include_string`, but at that point you might as well just paste into the REPL directly (caveat: different soft scope behavior) and saving a file on the server seems important. A reason I don’t like this massive text pasting is the parser doesn’t play nice with \>1 blank lines in one `String` (you do `"\n"` instead) or expression (check `begin` or `quote`); `include` works because it breaks up text into serially parsed expressions.

---

<div class="post-metadata">

### Author: ![world-peace](https://avatars.discourse-cdn.com/v4/letter/w/9f8e36/32.png) [@world-peace](https://discourse.julialang.org/u/world-peace)
#### Post date: [November 10, 2024, 8:30am UTC](https://discourse.julialang.org/t/how-to-use-the-repl-to-speed-up-modular-development-by-dynamically-replacing-function-definitions/122326/24 "2024-11-10T08:30:23Z")

</div>

> [@Benny](#):
>
> OP is saying the REPL and `vim` can’t be open at the same time on the server. Though I am curious what happens when `edit` is attempted. Does `vim` fail to open entirely? Does `vim` open but it’s impossible to switch to it from an active REPL?

Not quite.

There is only one terminal session which can be open at once.

You can open a REPL, press `;` and then run `vim`.

---

<div class="post-metadata">

### Author: ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)
#### Post date: [November 11, 2024, 12:45am UTC](https://discourse.julialang.org/t/how-to-use-the-repl-to-speed-up-modular-development-by-dynamically-replacing-function-definitions/122326/25 "2024-11-11T00:45:00Z")

</div>

Oh so there’s no desktop to open multiple windows in or terminal multiplexer, you just have the one active terminal to interact with, old-school workflow.

> [@world-peace](#):
>
> You can open a REPL, press `;` and then run `vim`.

Sounds good, you can exit `vim` to switch back to the same `Revise`-able REPL session. At least I can do that on Windows, downloaded `vim` to be sure:

```julia
julia> x = 1
1

shell> cd Downloads
C:\Users\redacted\Downloads

shell> powershell vim blah.txt

julia> include("blah.txt") # I wrote y = 2
2

julia> x, y
(1, 2)

```

Obviously loses out on features and ergonomics of an IDE or other editors, and I have to write `powershell vim` in Julia’s shell mode. But you can do that stuff locally and already can paste in the remote vim as a workaround if a remote desktop or multiplexer is a no-go.

---

<div class="post-metadata">

### Author: ![abraunst](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraunst/32/6880_2.png) [@abraunst](https://discourse.julialang.org/u/abraunst)
#### Post date: [November 12, 2024, 8:47am UTC](https://discourse.julialang.org/t/how-to-use-the-repl-to-speed-up-modular-development-by-dynamically-replacing-function-definitions/122326/26 "2024-11-12T08:47:13Z")

</div>

Is the command `rz` running on your machine, or can it be installed? `rz` and `sz` use the ZMODEM protocol to send files through a single serial terminal. It was popular in pre-internet times with modem connections 🙂. The linux package is sometimes called `lrzsz`.

Another thing: instead of using vim, maybe you can simply run from julia `run(`bash -c "cat > target.jl"`)`, then paste your code and end with control-D. You’ll save some keystrokes! (the above command will remain in your history of course)

---

<div class="post-metadata">

### Author: ![abraunst](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraunst/32/6880_2.png) [@abraunst](https://discourse.julialang.org/u/abraunst)
#### Post date: [November 12, 2024, 9:22am UTC](https://discourse.julialang.org/t/how-to-use-the-repl-to-speed-up-modular-development-by-dynamically-replacing-function-definitions/122326/28 "2024-11-12T09:22:37Z")

</div>

This has been already answered [here](https://discourse.julialang.org/t/how-to-use-the-repl-to-speed-up-modular-development-by-dynamically-replacing-function-definitions/122326/10) I think

[Previous page](https://discourse.julialang.org/t/how-to-use-the-repl-to-speed-up-modular-development-by-dynamically-replacing-function-definitions/122326.md?page=1)
