Failure using "g:" as a dict

13 views
Skip to first unread message

Ernie Rael

unread,
Mar 28, 2023, 6:45:40 PM3/28/23
to vim...@googlegroups.com

Doing

vim -c 'vim9cmd g:["my-output-dir"] = "vglob-dir"'

give this error

Error detected while processing command line:
E461: Illegal variable name: my-output-dir

Turns out

vim9script
g:["foo-bar"] = "baz"

also fails.

-ernie

Bram Moolenaar

unread,
Mar 31, 2023, 2:33:16 PM3/31/23
to vim...@googlegroups.com, Ernie Rael
Both errors are intended: You cannot use a dash in a variable name.

--
ARTHUR: Then who is your lord?
WOMAN: We don't have a lord.
ARTHUR: What?
DENNIS: I told you. We're an anarcho-syndicalist commune. We take it in
turns to act as a sort of executive officer for the week.
The Quest for the Holy Grail (Monty Python)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Ernie Rael

unread,
Mar 31, 2023, 4:03:44 PM3/31/23
to Bram Moolenaar, vim...@googlegroups.com
On 23/03/31 11:33 AM, Bram Moolenaar wrote:
>> Doing
>>
>> vim -c 'vim9cmd g:["my-output-dir"] = "vglob-dir"'
>>
>> give this error
>>
>> Error detected while processing command line:
>> E461: Illegal variable name: my-output-dir
>>
>> Turns out
>>
>> vim9script
>> g:["foo-bar"] = "baz"
>>
>> also fails.
> Both errors are intended: You cannot use a dash in a variable name.
>
OK. So "g:" can be treated as a dictionary as a convenience.
It's not really a dictionary.

-ernie

Reply all
Reply to author
Forward
0 new messages