-
-
Notifications
You must be signed in to change notification settings - Fork 292
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
Multiple outputs and inputs per cell #7
Comments
I don't see a reason why this shouldn't be legal from a paradigmatic point of view. I think this should be equivalent to two cells, one doing |
From a "how do we do this" point of view: I'd have variables rather than cells be the nodes of the dependency graph. Each cell can then execute imperative code; once it's done, the global variables it set are checked for changes, and changes are propagated down the graph. |
Internally splitting it up into two cells is a cool solution!
About having the core track variables instead of cells: not all cells
define variables - some are just expressions with output, package imports,
etc. so you would have to track all of them too.
But let's leave this for later?
|
More general then - we should track expressions. |
The issue of multiple expression per cell is solved: it is not legal. (To be clear, you can wrap multiple top-level expressions into a single We might re-open this one day, by making multiple expressions return multiple outputs. |
I'm sure this must have been discussed already, but why not allow multiple lines, and then just do the equivalent of implicitly wrapping in a This would not require having multiple outputs, and seems to make sense. |
Hey! This is a good question, it comes up often and I have spent some time thinking about it. Your suggested solution might be implemented some day, but I'd like to keep the current behaviour for now. The main reason is: Reactive notebooks work best if you split your code into multiple cells. For example, if you have a single cell defining 20 parameters for your model, then changing one parameter will cause the re-evaluation of every cell that (indirectly) depends on any parameter. This might be slow, making it less fun to play with your model (disaster!), and it's confusing - you feel like reactivity is not doing what it should do. SolutionSo you should make as many cells as you can! Problem solved? Well not quite, we get the feedback that cells can take up too much vertical space, and is more cumbersome to work with.
Two more argumentsLike I mentioned before, it might be confusing that changing a = 1
b = 2 to a = 1
b = 345 will also re-run all cells that depend on Also, I have a more geeky argument: But the main thing is: I want UI to motivate you to split your code into cells - it's still WIP but I think it will be nice. |
What if you took a page out of the REPL and instead of using different keys for evaluation versus newline, just used enter for both and as soon as the expression is complete, you evaluate? That would make it technically difficult to even enter two different expressions in a single block. And if someone does manage to do this (say but cut-and-paste), then you could just split the cell automatically into two. |
I love @StefanKarpinski's idea, what a great way to turn this situation into an opportunity! I find ctrl+enter shift+enter really frustrating, and a straight up REPL like experience would be amazing!! |
Note that this works in Julia but not in Python because in Python you can't tell when an expression ends. Fortunately, Pluto isn't trying to be a frontend for every language, so it doesn't have to worry about this 😁 |
Very nice! I was stuck on a similar idea, but this is realistic and cool. How about it doesn't run, but just creates and focuses a new cell? (Return to run makes me a bit scared in the REPL - Return is no longer a no-consequence button.) Instead, you have the shortcut Also nice would be to select multiple cells and then wrap them together into a And doing arrow-up/arrow-down should jump between cell borders, like pageup+pagedown right now. Exciting! |
What's the danger of evaluating code? I never have this worry in a normal REPL? Is it that one evaluation might trigger a lot of computation because of the reactive part? |
this is really ridiculous to not be able to run multiline codes in a cell without placing them in begin...end. at least have a config that this is possible. it is quiet obvious we group codes in the same cell. |
even the generated code with begin...end blocks are not really the default way you write code. |
This comment has been minimized.
This comment has been minimized.
Maybe this issue should be renamed to be about multiple inputs per cell, as it seems that the discussion has shifted more in this direction. |
The suggestions here are interesting and may be worth prototyping/exploring, but to me it seems like it basically boils down to how much credit you want to give the user, and right now I see things leaning towards not giving the user much credit (e.g. "hey user, you're not splitting things into enough cells because you don't understand that hurts reactivity, so we're going to do it for you", or "hey user, you're not going to realize chaging I would really encourage the opposite, give the user power, just make sure the rules are clear. The solution which corresponds to that to me is clear: implicilty wrap every cell in a a = 1
b = 2 in a single cell, why should Pluto make it impossible or at least annoying for them to do so (manually wrapping in |
exactly. why even to have this long thread to explain the importance of grouping logical blocks in a cell..... |
@ppalmes Please give us space to talk about this subject in a friendly way - your comments here and on slack are inappropriate. |
sorry. i’m just frustrated because it looks a very good package if the discussion is more open-minded instead of dismissing our point of view. thanks for taking into consideration the main point of discussion. |
I would like to reiterate the desire to allow for multi-line input without Clearly it is convenient, useful and arguably plain old sensical to let people to write more than one line of code in a single cell. The argument that notebooks might get less fun if they become slow is trumped (IMO) by the fact that it is even less fun to have to write Regarding the arguments above:
This might seem like an issue in theory, except that in practice I would expect parameters defined in a single cell to be logically related such that if another cell depends on one of the parameters, then it probably depends on at least some of the other parameters too. Conversely, I would not expect someone to define a bunch of parameters in a single cell that individually apply to different cells.
In this example, I would expect the cell that depends on |
We shouldn't let a hypothetical-worst-case performance issue dictate how we structure code given how important structure is to our reasoning process. |
I sympathize with the very real UI problem of displaying multiple outputs. And I like the idea of encouraging users to use the tool correctly, while giving them choice. A statement like From that perspective I think this should also be allowed: 🍕 = 1;
🥞 = 2 This also caters to both concerns: The UI problem is obviated because there is still only one statement with output, and allowing this form gives the user a choice of how they interact with the tool. |
What was wrong with the idea of just evaluating the cell and if the user presses enter when the input expression is complete? That seems like it solves this problem while also simplifying how input is done since one doesn't need to learn two different kinds if "enter" (plain enter versus "shift enter"). Then this issue simply doesn't come up since two separate expressions in one input cell becomes impossible to input in the first place. |
This is a good idea, indeed. But it does not solve everything, as there are plenty of legitimate cases where
The last ones require a cell to work as a unit (multiple outputs would not make sense). My preferred stance would be
But I understand why decisions about this are postponed. |
That does seem like a sensible approach: most users never need to think about anything besides |
it is great that this topic is still active. logical blocks just make sense because it is like writing multi-sentences vs multi-paragraph. the building block should be a paragraph and a sentence is the trivial case, not the rule. even adding ‘begin … end’ seems redundant if you have space separator or cell separator to signal different logical blocks. |
What about viewing expression cells that don't explicitly define variables as defining an |
I think it would be better to use the logging functionality or capturing of stdout (for println, etc.) for this purpose, see #437 |
My suggestion is to split this feature request into two separate requests: 1. Allow multiple inputs, 2. Allow multiple outputs. Then note that allowing multiple inputs incurs zero cost related to redesigning the architecture and UI, and is a pure UX benefit. The feature request to add multiple outputs can be considered separately. Allowing multiple inputs can be implemented conceptually very cleanly. First, note that allowing multiple inputs on the same line is already valid today, as stated in the opening post:
Conceptually, all but the last expression has it's output suppressed with
The biggest benefit of this design imo is that the user is very explicitly suppressing the output of prior expressions, and will not be surprised that multiple outputs are not displayed. Combined with ederag's comment that describes valid use-cases for multiple input lines (all of which I encountered the first time I used Pluto) this seems like a slam-dunk. |
Any further work on this? I think this is one of the main things holding me back from using Pluto instead of Quarto. |
MotivationI am currently in the process of extending Pluto to other languages (Python and R) where I also decided to allow for multiple lines. I return the last output, like what Jupyter would be doing, and what I think people expect. I would like to push this forward that Julia does not look more clunky than Python/R by always throwing errors if someone just uses multiple lines. My reasoning for auto-wrapping into begin-end blockReason one: Following the users intention of writing a single cell. The error gives two options: Splitting it up into multiple cells or wrapping it into a begin-end block. As a user, I apparently was writing a single cell, so my fallback intention is that I want a single cell. Reason two: Following users intention of jupyter notebook output. As said above, I am very happy to follow Jupyter output logic for Python and R. For Julia it would also mean returning the last output value only. |
A cell input like:
should not be legal, because it is not a single expression. This might be unexpected (and part of the learning curve) for new users, and we could accept it without breaking the paradigm by:
A nice hybrid solution is to do the first option, and to design the editor layout in such a way that all cells fluently follow each other. (If code is folded).
Note:
The cell
which is syntactic sugar for
is a single expression, which is not an assignment, but an evaluation that performs two global assignments. Parsing this cell should be legal (as a single expression), but running it might give an error (depending on what we decide to do with globals).
The text was updated successfully, but these errors were encountered: