> For now I'm using
>
> export def IsInstanceOf(o: any, type: string): bool
> return type(o) == v:t_object && type == typename(o)[7 : -2]
> enddef
>
> Is there something better? A planned builtin?
>
> I don't actually need it yet, but I'm just getting started and I know
> how I am.
Implementing "instanceof" is in the todo list. I haven't looked into
the details yet. Probably similar to how Java works. Although I have
always found it a bit confusing that it results in true for an object
that is a child of the class being tested with.
I have also been thinking of an alternative of type() that includes the
exact class. So that you could do:
type_ext(object) == type_ext(SomeClass.new())
Similar to typename(), except that it would make a difference between
classes with the same name declared in different scripts. Hmm, perhaps
adding the script number would work? Thus if you define a class MyClass
in script 4 and script 7, you would get:
object<MyClass/4>
object<MyClass/7>
This win't work if a class can be defined more than once in one script
file. E.g. when it's local to a function. An alternative is to give
each encountered class a unique number.
--
hundred-and-one symptoms of being an internet addict:
112. You are amazed that anyone uses a phone without data...let
alone hear actual voices.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20230210205020.66B991C0830%40moolenaar.net.