On 3/6/22 5:49 AM, Bram Moolenaar wrote:

Yes, that is the problem we need to tackle.  Considering the above, how
about introducing different null types:

        null_string
        null_dict
        null_list
        null_function
        null_partial
        null_channel
        null_job

That will allow for clearing a script-local variable, while keeping the
type.  And it allows for using a null value in a dict or list while
keeping the type.

This scheme certainly satisfies my requirements. One question, there's

        if jobs.write != null_job

but what about

        var sval = ''
        if sval == null_string

is this true or false? Or is string a special case and you need

        if sval is null_string

Requiring 'is' is confusing

-ernie



Another example, consider preparing a list with jobs, but the jobs have
not been created yet:
        var jobs = {read: null_job, write: null_job, check: null_job}
        ...
        jobs.read = job_start(...)
        if writing
           jobs.write = job_start(...)
        endif
        jobs.check = job_start(...)
        ...
        if jobs.write != null_job
          # write
        endif

This looks better than just using "null" and handling the type
difference in some way.

Another problem not mentioned yet: When using a default value for a
function argument, and the type is channel, there was no value that
could be used.  null_channel would be useful there too.

--
--
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/811d3a5f-f0c7-619d-e9a1-8b47f1c3ab89%40raelity.com.

Raspunde prin e-mail lui