Re: Vim9: rethinking conditions and boolean expressions

2020-10-05 Fir de Conversatie Ben Jackson
> The "??" operator is used in TypeScript, JavaScript, C# and a few other > > languages. Oh ok, fair enough, thanks. Shows how much I know :) I’d never seen it before. > On 5 Oct 2020, at 14:20, Bram Moolenaar wrote: > > >>> var name = Getname() ?? 'unknown' >> >> This `??` operator seems a

Re: Vim9: rethinking conditions and boolean expressions

2020-10-05 Fir de Conversatie Bram Moolenaar
> > var name = Getname() ?? 'unknown' > > This `??` operator seems a bit unique to vim9script. If we're trying to be > more like other languages how about either re-using `else` (as in Getname() > else 'unknown') or using `or` (Like python): `Getname() or "unknown"` Python operators are word

Re: Vim9: rethinking conditions and boolean expressions

2020-10-05 Fir de Conversatie Bram Moolenaar
Dominique wrote: > Bram Moolenaar wrote: > > > For the first example, we can use a new operator which is specifically > > for testing an expression to be falsy and using a replacement: > > > > var name = Getname() ?? 'unknown' > > > > Let me know if you have comments. > > This is know

Re: Vim9: rethinking conditions and boolean expressions

2020-10-05 Fir de Conversatie Dominique Pellé
Bram Moolenaar wrote: > For the first example, we can use a new operator which is specifically > for testing an expression to be falsy and using a replacement: > > var name = Getname() ?? 'unknown' > > Let me know if you have comments. This is known as the 'elvis operator', which exists

Re: Vim9: rethinking conditions and boolean expressions

2020-10-05 Fir de Conversatie puremo...@gmail.com
> var name = Getname() ?? 'unknown' This `??` operator seems a bit unique to vim9script. If we're trying to be more like other languages how about either re-using `else` (as in Getname() else 'unknown') or using `or` (Like python): `Getname() or "unknown"` On Sunday, October 4, 2020 at 10:47:

Re: Vim9: rethinking conditions and boolean expressions

2020-10-04 Fir de Conversatie Bram Moolenaar
> In javascript you can use !! operator to always convert it to boolean. > > var name = '' > var nameExists = !!(name || 'Prabir') Yes, and I think we should do the same. It should already work like that now. Thus in most places where a condition is expected, such as with ":if" and ":while",

Re: Vim9: rethinking conditions and boolean expressions

2020-10-04 Fir de Conversatie ma...@prabir.me
In javascript you can use !! operator to always convert it to boolean. var name = '' var nameExists = !!(name || 'Prabir') On Saturday, October 3, 2020 at 12:25:21 PM UTC-7 Andy Wokula wrote: > Am 03.10.2020 um 17:44 schrieb Bram Moolenaar: > > Therefore, I'm going to make && and || have a boole

Re: Vim9: rethinking conditions and boolean expressions

2020-10-03 Fir de Conversatie 'Andy Wokula' via vim_dev
Am 03.10.2020 um 17:44 schrieb Bram Moolenaar: Therefore, I'm going to make && and || have a boolean result again. I think that is the easiest to understand, and what most languages do. +100 -- Andy -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply

Vim9: rethinking conditions and boolean expressions

2020-10-03 Fir de Conversatie Bram Moolenaar
As a first approach I have used what TypeScript does. However, considering the feedback I have received, it's not very consistent and has a few surprising sides. One thing is that the "||" and "&&" operators do not result in a boolean true or false, but the argument value. This is nice for som