3 ms·
Comments Section In Next Generation Shell I've experimented by adding section "arbitrary comment" { code here } and this is staying in the lang
by ilyash 4y ago
Comments Section
In Next Generation Shell I've experimented by adding
section "arbitrary comment" {
code here
}
and this is staying in the language. It looks good. That's instead of
# blah section - start
code here
# blah section - end
Later, since NGS knows about sections, I can potentially add section info to stack traces (also maybe logging and debugging messages). At the moment, it's just an aesthetic comments and (I think) easily skip-able code section when reading.
Symbols
I've decided not to have symbols in NGS. My opinion (I assume not popular) is that all symbols together is one big enum, instead of having multiple enums which would convey which values are acceptable at each point.
- Bilal_io 4y agoYou can do something similar in JavaScript > const love = "love"; > { // Section > console.log(`What is ${love}`); > }
- ilyash 4y agoNot the same ergonomic. The language doesn't "understand" it's a section (no opportunities listed in the original comment).
- zdragnar 4y agoActually, it does, though the only real use is with the `break` keyword for breaking out of a labelled block (or break / continue in a for loop): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... Things like stack traces don't track them, unfortunately.
- Beltalowda 4y agoI sometimes do something like: var foo string { // Do stuff // ... foo = "..." } { // Other section... } You can also split stuff up in to sections, but for some kind of functions where you know the functions will never be re-used and are intimately related, I find this clearer. Of course, your language will need to have block scope, or at least blocks.
- kgeist 4y agoC# has #region/endregion They are foldable in IDEs
- still_grokking 4y agoAnd the result is people writing 10k LOC files. I'm not sure this is the right approach…
- lelanthran 4y agoIf it's just for comments, IIRC Lisp has docstrings - the very first expression in a Lisp function can be a string literal which gets compiled into the final executable as a docstring which can be retrieved at runtime.