Re: Comments halfway continuation lines
Andy Wokula wrote: > Am 19.08.2018 um 18:37 schrieb Bram Moolenaar: > > Currently, when making a list with continuation lines, it is not > > possible to add a comment somewhere: > > > > let array = [ > > \ item, > > \ item, > > \ item, > > \] > > Maybe you can't put a comment, but you can put something that is (evaluated > but) ignored > and serves as a comment: > > let array = [ > \ ['item', "my fancy comment for this item"][0], > \ ['item2', "I like this item much more than the first item"][0], > \ ['item3', "Is this a stupid way to comment items??"][0], > \ ['item4', "I don't think so"][0], > \ ['item5', "true: there is some unnecessary computation going on"][0], > \ ['item6', "but it's negligible, right?"][0], > \ ['item7', "right"][0], > \ ] > > echo array > => ['item', 'item2', 'item3', 'item4', 'item5', 'item6', 'item7'] That's clever, but I would not enjoy reading your script! :-) -- Clothes make the man. Naked people have little or no influence on society. -- Mark Twain (Samuel Clemens) (1835-1910) /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net \\\ ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org/// \\\help me help AIDS victims -- http://ICCF-Holland.org/// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Comments halfway continuation lines
Am 19.08.2018 um 18:37 schrieb Bram Moolenaar: Currently, when making a list with continuation lines, it is not possible to add a comment somewhere: let array = [ \ item, \ item, \ item, \] Maybe you can't put a comment, but you can put something that is (evaluated but) ignored and serves as a comment: let array = [ \ ['item', "my fancy comment for this item"][0], \ ['item2', "I like this item much more than the first item"][0], \ ['item3', "Is this a stupid way to comment items??"][0], \ ['item4', "I don't think so"][0], \ ['item5', "true: there is some unnecessary computation going on"][0], \ ['item6', "but it's negligible, right?"][0], \ ['item7', "right"][0], \ ] echo array => ['item', 'item2', 'item3', 'item4', 'item5', 'item6', 'item7'] -- Andy -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Comments halfway continuation lines
P.S. Inside a single-quoted string, \c means "backslash followed by c" and we want to keep that; so I propose the following three constructs: '\c ... some comment ... \c '\c ... some comment ... \c' '\c ... some comment ... \c'' (all inside an already-started single-quoted comment) to mean (I'm not sure in what sequence): - the single-quoted string ends at the comment - the single-quoted string is interrupted by a comment and continues thereafter - the single-quoted string is interrupted by a comment and continues thereafter with an embedded single-quote character. Best regards, Tony. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Comments halfway continuation lines
On Mon, Aug 20, 2018 at 1:18 PM, Bram Moolenaar wrote: > > Tony Mechelynck wrote: >> [...] >> Fixed-form COBOL (the only kind I knew), where comments had to be on >> their own lines (with an asterisk in column 7 IIRC), and continuation >> lines had a dash in the otherwise unused column 7, had strict rules >> about how to represent quoted strings (which could be up to 120 >> characters long) on punched cards where the useful part of unlabeled >> lines was 61 characters including the starting quote (from column 12 >> to column 72 inclusive) but these are not germane to Vim and I do not >> propose to introduce anything similar into Vim script language. > > Well, the special character sequence to put in front of a comment in > between continuation lines is something like that. > Hm. This would be hard to decide, because inside a double-quoted string about anything can be used and becomes part of the string, with the proviso that a backslash can be used to escape certain special characters. Repeating the opening quote COBOL-like immediately after the continuation backslash is of course excluded, as it would break compatibility. Maybe we need some new syntax for comments which end before the end of the line, but how to define that without changing the meaning of some already useful syntax construct, especially inside a double-quoted string? Maybe \c (which at the moment means nothing AFAIK) and end the comment with another \c (but \\c would mean, as it already does, "backslash followed by c"). There might be a problem with Windows pathnames. Then maybe start with "\c and end with \c. No, that would clash with existing end-of-line comments. Well, then \c but precede it with a space if it would otherwise be interpreted as part of a pathname (since on Windows, a top-level path is not indicated by a starting backslash but by a drive letter followed by a colon). Inside double-quoted strings, backslashes are "special" anyway and I would (even with no change to the existing code) strongly recommend _not_ to use single backslashes to represent a Windows path inside a double-quoted string: so if has('win32' || has('win64')) let filepathname = "%USERPROFILE%\\this\\and\\that\\filename.ext" endif or the same with _single_ quotes and single backslashes, but not double quotes and single backslashes (other than when intentionally using them for their "special" meanings as under ":help expr-quote"), as this would already produce unexpected results if the character following the backslash is any of X x U u b e f n r t Best regards, Tony. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Comments halfway continuation lines
Tony Mechelynck wrote: > On Mon, Aug 20, 2018 at 10:06 AM, Bram Moolenaar wrote: > > > >> On Monday, August 20, 2018 at 1:37:53 AM UTC+9, Bram Moolenaar wrote: > >> > Currently, when making a list with continuation lines, it is not > >> > possible to add a comment somewhere: > >> > > >> > let array = [ > >> > \ item, > >> > \ item, > >> > \ item, > >> > \] > >> > > >> > Adding a comment after the comma causes all the rest to be included in > >> > the comment: > >> > > >> > let array = [ > >> > \ item, > >> > \ item, " comment > >> > \ item, > >> > \] > >> > > >> > Since this is equivalent to: > >> > > >> > let array = [ item, item, " comment item, ] > >> > > >> > Simple solutions will such as using \" fail, because just about anything > >> > following the backslash is valid if we are inside a string: > >> > > >> > echo "some > >> > \ word > >> > \" comment > >> > \ word > >> > > >> > Is equivalent to the valid command: > >> > > >> > echo "some word" comment word > >> > > >> > So, a line starting with a backslash can't be used for a comment. > >> > Thinking about what would work (that is, currently it is an error), I > >> > thought of using |\": > >> > > >> > let array = [ > >> > \ item, > >> > |\" comment > >> > \ item, > >> > \] > >> > > >> > It looks a bit weird, but it would work. Any thoughts? > >> > > >> > >> I like this. > >> > >> https://go-gyazo.appspot.com/04e22439cfdc859e.png > >> > >> Most of people expect comments can be written as syntax is. > > > > Unfortunately, that currently is valid syntax, especially when the line > > continuation is used for a long string. The parsing happens after all > > the continuation lines are joined, it's not really possible before that. > > It is indeed is valid syntax, but is it used anywhere? When > floating-point numbers were introduced into Vim, it was decided that > using 1.5 to mean "the floating number one and a half" rather than, as > before, "the string form of the integer 1 concatenated to the string > form of the integer 5", i.e. the string "15" wasn't harmful. An important difference is that there is no reason to write 1.5 to get "15". It's quite safe to assume that nobody has written that in a script. While it is very well possible that someone wrote: let s = " \some text \ some more text \" It's actually quite nice to be able to write it that way, we should not stop supporting that. > Would it be harmful to require than long strings be represented as > >"aaa" > \. "bbb" > \. "ccc" > > with both quotation marks on the same physical line and concatenation > by . if necessary, and not > > "aaa > \bbb > \ccc" > > with a long string expanding over two or more continued lines? If it > wouldn"t, then I suppose it would be possible to add to the parser a > "preprocessor" whose sole task would be to remove comments (from the > unpaired double-quote to the end of the physical line regardless of a > possible continuation line). There would be an ambiguity in the case > of more than one double quote on a single line, but that is already > handled in the case of strings vs. comments in expressions, or when > using registers in the operand of :normal, or anywhere in the case of > @" which does not _have_ to be represented by @@ Currently the parsing happens after joining all the continuation lines. To do what you want we would need to join a line, parse it, join another line, parse it, etc. The only way parsing works reliably is to do it from the start. Starting the parsing at an arbitrary part of the line isn't really possible. You never know where the continuation happens. And parsing the line multiple times is a big performance penalty. > Fixed-form COBOL (the only kind I knew), where comments had to be on > their own lines (with an asterisk in column 7 IIRC), and continuation > lines had a dash in the otherwise unused column 7, had strict rules > about how to represent quoted strings (which could be up to 120 > characters long) on punched cards where the useful part of unlabeled > lines was 61 characters including the starting quote (from column 12 > to column 72 inclusive) but these are not germane to Vim and I do not > propose to introduce anything similar into Vim script language. Well, the special character sequence to put in front of a comment in between continuation lines is something like that. > The alternative to Yatsuhiro's proposal, which is elegant and which I > endorse despite its break with backward compatibility, is to break > expressions over comments, which can already be d
Re: Comments halfway continuation lines
On Mon, Aug 20, 2018 at 10:06 AM, Bram Moolenaar wrote: > >> On Monday, August 20, 2018 at 1:37:53 AM UTC+9, Bram Moolenaar wrote: >> > Currently, when making a list with continuation lines, it is not >> > possible to add a comment somewhere: >> > >> > let array = [ >> > \ item, >> > \ item, >> > \ item, >> > \] >> > >> > Adding a comment after the comma causes all the rest to be included in >> > the comment: >> > >> > let array = [ >> > \ item, >> > \ item, " comment >> > \ item, >> > \] >> > >> > Since this is equivalent to: >> > >> > let array = [ item, item, " comment item, ] >> > >> > Simple solutions will such as using \" fail, because just about anything >> > following the backslash is valid if we are inside a string: >> > >> > echo "some >> > \ word >> > \" comment >> > \ word >> > >> > Is equivalent to the valid command: >> > >> > echo "some word" comment word >> > >> > So, a line starting with a backslash can't be used for a comment. >> > Thinking about what would work (that is, currently it is an error), I >> > thought of using |\": >> > >> > let array = [ >> > \ item, >> > |\" comment >> > \ item, >> > \] >> > >> > It looks a bit weird, but it would work. Any thoughts? >> > >> > -- >> > Mynd you, m00se bites Kan be pretty nasti ... >> > "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES >> > LTD >> > >> > /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net \\\ >> > ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ >> > \\\ >> > \\\ an exciting new programming language -- http://www.Zimbu.org >> > /// >> > \\\help me help AIDS victims -- http://ICCF-Holland.org/// >> >> I like this. >> >> https://go-gyazo.appspot.com/04e22439cfdc859e.png >> >> Most of people expect comments can be written as syntax is. > > Unfortunately, that currently is valid syntax, especially when the line > continuation is used for a long string. The parsing happens after all > the continuation lines are joined, it's not really possible before that. > > -- > ARTHUR: It is I, Arthur, son of Uther Pendragon, from the castle of Camelot. > King of all Britons, defeator of the Saxons, sovereign of all England! >[Pause] > SOLDIER: Get away! > "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD > > /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net \\\ > ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ > \\\ an exciting new programming language -- http://www.Zimbu.org/// > \\\help me help AIDS victims -- http://ICCF-Holland.org/// It is indeed is valid syntax, but is it used anywhere? When floating-point numbers were introduced into Vim, it was decided that using 1.5 to mean "the floating number one and a half" rather than, as before, "the string form of the integer 1 concatenated to the string form of the integer 5", i.e. the string "15" wasn't harmful. Would it be harmful to require than long strings be represented as "aaa" \. "bbb" \. "ccc" with both quotation marks on the same physical line and concatenation by . if necessary, and not "aaa \bbb \ccc" with a long string expanding over two or more continued lines? If it wouldn"t, then I suppose it would be possible to add to the parser a "preprocessor" whose sole task would be to remove comments (from the unpaired double-quote to the end of the physical line regardless of a possible continuation line). There would be an ambiguity in the case of more than one double quote on a single line, but that is already handled in the case of strings vs. comments in expressions, or when using registers in the operand of :normal, or anywhere in the case of @" which does not _have_ to be represented by @@ Fixed-form COBOL (the only kind I knew), where comments had to be on their own lines (with an asterisk in column 7 IIRC), and continuation lines had a dash in the otherwise unused column 7, had strict rules about how to represent quoted strings (which could be up to 120 characters long) on punched cards where the useful part of unlabeled lines was 61 characters including the starting quote (from column 12 to column 72 inclusive) but these are not germane to Vim and I do not propose to introduce anything similar into Vim script language. The alternative to Yatsuhiro's proposal, which is elegant and which I endorse despite its break with backward compatibility, is to break expressions over comments, which can already be done with the current code, and would remain valid syn
Re: Comments halfway continuation lines
> On Monday, August 20, 2018 at 1:37:53 AM UTC+9, Bram Moolenaar wrote: > > Currently, when making a list with continuation lines, it is not > > possible to add a comment somewhere: > > > > let array = [ > > \ item, > > \ item, > > \ item, > > \] > > > > Adding a comment after the comma causes all the rest to be included in > > the comment: > > > > let array = [ > > \ item, > > \ item, " comment > > \ item, > > \] > > > > Since this is equivalent to: > > > > let array = [ item, item, " comment item, ] > > > > Simple solutions will such as using \" fail, because just about anything > > following the backslash is valid if we are inside a string: > > > > echo "some > > \ word > > \" comment > > \ word > > > > Is equivalent to the valid command: > > > > echo "some word" comment word > > > > So, a line starting with a backslash can't be used for a comment. > > Thinking about what would work (that is, currently it is an error), I > > thought of using |\": > > > > let array = [ > > \ item, > > |\" comment > > \ item, > > \] > > > > It looks a bit weird, but it would work. Any thoughts? > > > > -- > > Mynd you, m00se bites Kan be pretty nasti ... > > "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES > > LTD > > > > /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net \\\ > > ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ > > \\\ an exciting new programming language -- http://www.Zimbu.org/// > > \\\help me help AIDS victims -- http://ICCF-Holland.org/// > > I like this. > > https://go-gyazo.appspot.com/04e22439cfdc859e.png > > Most of people expect comments can be written as syntax is. Unfortunately, that currently is valid syntax, especially when the line continuation is used for a long string. The parsing happens after all the continuation lines are joined, it's not really possible before that. -- ARTHUR: It is I, Arthur, son of Uther Pendragon, from the castle of Camelot. King of all Britons, defeator of the Saxons, sovereign of all England! [Pause] SOLDIER: Get away! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net \\\ ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org/// \\\help me help AIDS victims -- http://ICCF-Holland.org/// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Comments halfway continuation lines
On Monday, August 20, 2018 at 1:37:53 AM UTC+9, Bram Moolenaar wrote: > Currently, when making a list with continuation lines, it is not > possible to add a comment somewhere: > > let array = [ > \ item, > \ item, > \ item, > \] > > Adding a comment after the comma causes all the rest to be included in > the comment: > > let array = [ > \ item, > \ item, " comment > \ item, > \] > > Since this is equivalent to: > > let array = [ item, item, " comment item, ] > > Simple solutions will such as using \" fail, because just about anything > following the backslash is valid if we are inside a string: > > echo "some > \ word > \" comment > \ word > > Is equivalent to the valid command: > > echo "some word" comment word > > So, a line starting with a backslash can't be used for a comment. > Thinking about what would work (that is, currently it is an error), I > thought of using |\": > > let array = [ > \ item, > |\" comment > \ item, > \] > > It looks a bit weird, but it would work. Any thoughts? > > -- > Mynd you, m00se bites Kan be pretty nasti ... > "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD > > /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net \\\ > ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ > \\\ an exciting new programming language -- http://www.Zimbu.org/// > \\\help me help AIDS victims -- http://ICCF-Holland.org/// I like this. https://go-gyazo.appspot.com/04e22439cfdc859e.png Most of people expect comments can be written as syntax is. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Comments halfway continuation lines
On Sun, Aug 19, 2018 at 6:37 PM, Bram Moolenaar wrote: > > Currently, when making a list with continuation lines, it is not > possible to add a comment somewhere: > > let array = [ > \ item, > \ item, > \ item, > \] > > Adding a comment after the comma causes all the rest to be included in > the comment: > > let array = [ > \ item, > \ item, " comment > \ item, > \] > > Since this is equivalent to: > > let array = [ item, item, " comment item, ] > > Simple solutions will such as using \" fail, because just about anything > following the backslash is valid if we are inside a string: > > echo "some > \ word > \" comment > \ word > > Is equivalent to the valid command: > > echo "some word" comment word > > So, a line starting with a backslash can't be used for a comment. > Thinking about what would work (that is, currently it is an error), I > thought of using |\": > > let array = [ > \ item, > |\" comment > \ item, > \] > > It looks a bit weird, but it would work. Any thoughts? > > -- > Mynd you, m00se bites Kan be pretty nasti ... > "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD > > /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net \\\ > ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ > \\\ an exciting new programming language -- http://www.Zimbu.org/// > \\\help me help AIDS victims -- http://ICCF-Holland.org/// In the case of a List, you can construct it by concatenation, though it might be a little slower at run-time, depending on how densely you want to comment: let array = [ \ "one", \ "two", \ ] " three is intentionally omitted call extend(array, [ \ "four", \ "five", \ "six", \ ]) Similarly I suppose for other arithmetic operations: hold the temporary results in one or more variables, insert the comment after temporarily ending the computation, and go on from there. Best regards, Tony. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Comments halfway continuation lines
Currently, when making a list with continuation lines, it is not possible to add a comment somewhere: let array = [ \ item, \ item, \ item, \] Adding a comment after the comma causes all the rest to be included in the comment: let array = [ \ item, \ item, " comment \ item, \] Since this is equivalent to: let array = [ item, item, " comment item, ] Simple solutions will such as using \" fail, because just about anything following the backslash is valid if we are inside a string: echo "some \ word \" comment \ word Is equivalent to the valid command: echo "some word" comment word So, a line starting with a backslash can't be used for a comment. Thinking about what would work (that is, currently it is an error), I thought of using |\": let array = [ \ item, |\" comment \ item, \] It looks a bit weird, but it would work. Any thoughts? -- Mynd you, m00se bites Kan be pretty nasti ... "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net \\\ ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org/// \\\help me help AIDS victims -- http://ICCF-Holland.org/// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.