Tuesday, May 7, 2024

Re: Access class member from command line

Looks like a bug. Should be able to do `foo.Config.option = true`

```
Items in a class ~
*E1318* *E1325* *E1388*
Inside a class, in between `:class` and `:endclass`, these items can appear:
- An object variable declaration: >
var _protectedVariableName: memberType
var readonlyVariableName: memberType
public var readwriteVariableName: memberType
- A class variable declaration: >
static var _protectedClassVariableName: memberType
static var readonlyClassVariableName: memberType
public static var readwriteClassVariableName: memberType

```
On Sunday 5 May 2024 at 15:39:53 UTC+2 Lifepillar wrote:
Let's say I have this class in some `foo.vim` file:

export class Config
public static var option = false
endclass

Now, I'd like to set `Config.option` to `true` from a script and from
the command line. From a script, I can do this:

import `foo.vim`

type FooConfig = foo.Config
FooConfig.option = true
echo FooConfig.option # OK
echo foo.Config.option # Also works

Unfortunately, this gives an error (Undefined variable Config):

foo.Config.option = true

But how do I access the class member from the command line? Is that even
possible?

Context: I'm exploring alternatives to `g:myplugin_option` to configure
a script without using global variables.

Thanks,
Life.

--
--
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/0ad05182-8aa2-467a-8bbf-2b1b32f19811n%40googlegroups.com.

No comments:

Post a Comment