Multi-Line structures and in-line comments.
Created by: jwarner112
Hello,
I'm playing with Ion shell right now and it's so far proven to be very powerful. I'm looking forward to the way this project develops, as well as maybe being a contributor some time soon.
One problem I'm encountering where Bash has proven superior is in multi-line arrays. In Bash:
paths=(
"/opt/bin" `# A comment`
"/bin" `# Another comment`
"/usr/bin" `# Yet another comment`
"/usr/local/bin" `# Some kind of comment I guess?`
)
This is a sequence that allows me to neatly edit my $PATH
with all the above paths, and the backtick trick allows me to have inline comments explaining what each one is. The example is trivial but in production I make good use of this. I'd rather not need the backtick hack, but that's the only way to get the desired behavior.
In Ion, there appears to be no equivalent-- I can't get inline comments and can't get a #
to simultaneously respect the final \
without the shell crashing on me.
I'm looking to discuss possible solutions, ranging from a simple inline-comment syntax to even a special syntax for collections that span multiple lines. For example, I like the way this looks:
let paths = [
/opt/bin, # The quotes here are optional
/bin, # I left them out of this example because what the hey
/usr/bin, # the ',' character tells Ion explicitly not to IGNORE the newline,
/usr/local/bin, # but omit it when storing the array, so that the comment can properly be dropped
# mixed feelings on this end comment
# And also on this last-element-trailing-comma, but I normally work in Python
];
Still, it might be easier to implement this:
let paths = [ \
/opt/bin /*Inline comment that ends here ->*/ \
/bin /*Another comment*/ \
/usr/local/bin /*You get the idea*/ \
];
Thoughts?
Build information:
jwarner:~$ rustup -V
rustup 1.5.0 (92d0d1e9e 2017-06-24)
jwarner:~$ rustc -V
rustc 1.19.0 (0ade33941 2017-07-17)
jwarner:~$ cargo -V
cargo 0.20.0 (a60d185c8 2017-07-13)
jwarner:~$ uname -a
Linux jwarner 4.4.0-81-generic #104~14.04.1-Ubuntu SMP Wed Jun 14 12:45:52 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
jwarner:~$ # ion-shell = 1.0.5 (but can't find where to get that via CLI)