On Mon, Feb 8, 2016 at 6:48 PM, Bram Moolenaar <[email protected]> wrote:
>
> [adjusted the subject, it was "Why is v:none needed"]
>
> Takuya Fujiwara wrote:
>
>> > [...]
>> >
>> > > >>     let json = jsonencode({"key": v:none})
>> > > >>     if json is v:none
>> > > >>         echoerr 'error!'
>> > > >>         return ...
>> > > >>     endif
>> > > >
>> > > > Well, let's just return an empty string.  Returning a different type
>> > > > often makes it more complicated.
>> > >
>> > > I agree.
>> > > However, I think "E706: Variable type mismatch" should be removed
>> > > becase it is not so useful for me...
>> >
>> > Where do you get that?  Or do you mean that the sticky type checking
>> > isn't all that useful in general?  I've been wondering whether we would
>> > be better off without it.
>>
>> I don't think it is useful in lightweight languages
>> (I don't think *only* a strict type checking is useful).
>> A strict type checking is useful for a language which has a strong type
>> system.
>> Because we can detect errors by different types, and so on.
>
> At the time it seemed like a good idea, to have some type checking to
> avoid mistakes.  Over time I can't say this has uncovered a problem. I
> did run into the error when I didn't want it.  Currently I think we
> might be better off without it.
>
> So, let's ask: who finds the sticky type checking useful?

+1.

I'll show a example here, why we might be better off a sticky type checking.

for i in ['foo', 'bar', {'key': 'baz'}]
  echo string(i)
endfor

Will output:

'foo'
'bar'
E706: Variable type mismatch for: i

We need 'unlet i'.
It is easy to miss it...

for i in ['foo', 'bar', {'key': 'baz'}]
  echo string(i)

  " If you :continue here, you need to :unlet in the condition, too...
  if ...
    unlet i
    continue
  endif

  " We need this always!
  unlet i
endfor


>
> --
> hundred-and-one symptoms of being an internet addict:
> 178. You look for an icon to double-click to open your bedroom window.
>
>  /// Bram Moolenaar -- [email protected] -- 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui