UI review: jshell commands
John Rose
john.r.rose at oracle.com
Mon Jun 29 21:37:37 UTC 2015
On Jun 29, 2015, at 12:21 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
>
> I want the user to quickly internalize that a) there *is* a startup file, and b) that things read from the startup file are handled "as if" the user typed them.
Perhaps I'm missing the point of this "as if" rule, but to me it seems like more of a recurrent pitfall than a help.
Auto-generated names like $1 are not useful when imported from another scope (like a startup file); they are only useful interactively.
If the creator of the startup file wants to export names, it is trivial to edit them in, and easier to ensure that the user will know how to name them interactively:
// startup starts here
int theHostId = getHostId();
// end of startup
1+1;
$1 = 2
theHostid;
$2 = 42
Otherwise, the intermediate results of the startup file should be dropped. Or at least they should not interfere with the auto-generated names for interactive results.
Two compromises possible on that:
1. If for some reason we must, auto-generate a different set of names for the startup file, starting with $_ (think, "negative") or $0:
1+1;
$1 = 2;
$_1; // host id from startup, etc.
2. If you buy my argument that auto-generated things are usually useless, have an opt-in argument for those special times when you need auto-numbering of the file. Replaying a previous interactive input is really a different use case from reusing a common profile.
Such a special time would be replaying scripts, but I can't think of any other. Perhaps that is envisioned as the default. In that case, we should be sure that it in the *other default*, when pulling from a startup file like ~/.kullarc, it should be easy to suppress the creation of $N variables.
— John
More information about the kulla-dev
mailing list