Thursday, December 3, 2020

Re: Vim9 dict key notation old fashion depreciated

Filipe Contreras wrote:

> On Thursday, December 3, 2020 at 5:34:04 AM UTC-6 Bram Moolenaar wrote:
>
> > Looks like your problem is with the "fg+" key, the plus character is not
> > allowed in a literal key. You can use the Javascript notation, using
> > square brackets:
>
> ['fg+']: ["fg", "CursorLine", "CursorColumn", "Normal"],
>
>
> What's wrong with 'fg+'? In JavaScript there's no need for brackets. It's
> there for want to you use a variable.

In the browser console:

var d = {key+: 'value'}
% Uncaught SyntaxError: Unexpected token '+'

We do allow for the underscore and minus sign. We could allow for a few
more, but it can get confusing. Javascript doesn't even allow for the
minus sign.

Oh, you mean using single quotes without the brackets works. Double
quotes too. That is simpler. Somehow I didn't find this in the
specification. I see questions on stack overflow from more people who
are confused about this. Only for JSON it's clear that double quotes
are always required.


--
TALL KNIGHT: We are now no longer the Knights Who Say Ni!
ONE KNIGHT: Ni!
OTHERS: Sh!
ONE KNIGHT: (whispers) Sorry.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Bram@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_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/202012031610.0B3GAhgR240800%40masaka.moolenaar.net.

No comments:

Post a Comment