Bjorn Linse wrote:

> > Internally a list with a NULL pointer is supposed to be handled like an
> > empty list.  This is efficient, but tricky.  Nikolai just sent a patch,
> > hopefully that helps.
> 
> Good, but I wonder if it is not better for getreg("a",1,1) to always
> return a mutable list (an empty mutable list in this case)? Because as
> it returns a mutable list for a register with contents (
> setreg("a",'x') ) or an empty one ( setreg("a",'') ) a plugin writer
> might come to expect that it always returns a fresh mutable list, but
> this then fails for an undefined register ( setreg("a",[]) ). Isn't
> API consistency better that a little bit of efficiency, in this case?

The NULL is supposed to be the same as an empty, mutable list.  This is
tricky, because code that expects a list needs to check for the NULL and
create the list if needed.

An alternative would be to create an empty list instead of using a NULL.
However, that requires memory allocation and there will still always be
the chance of getting a NULL anyway (out of memory, mistake in the code).

We could also consider NULL and invalid list, but I would think that
puts the burden on the script writer.

-- 
GUARD #1:  What, ridden on a horse?
ARTHUR:    Yes!
GUARD #1:  You're using coconuts!
ARTHUR:    What?
GUARD #1:  You've got two empty halves of coconut and you're bangin' 'em
           together.
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- b...@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_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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui