Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #33714 > unrolled thread

why the ! operator can be used to determine a string is null?

Started byXue Feng <xf.lotus@yahoo.com>
First post2017-08-08 23:43 +0800
Last post2017-08-10 18:52 +0200
Articles 20 on this page of 36 — 10 participants

Back to article view | Back to comp.lang.javascript


Contents

  why the ! operator can be used to determine a string is null? Xue Feng <xf.lotus@yahoo.com> - 2017-08-08 23:43 +0800
    Re: why the ! operator can be used to determine a string is null? Robert Heller <heller@deepsoft.com> - 2017-08-08 11:16 -0500
    Re: why the ! operator can be used to determine a string is null? Jon Ribbens <jon+usenet@unequivocal.eu> - 2017-08-08 17:40 +0000
      Re: why the ! operator can be used to determine a string is null? Julio Di Egidio <julio@diegidio.name> - 2017-08-08 21:38 -0700
        Re: why the ! operator can be used to determine a string is null? John G Harris <niam@jghnorth.org.uk.invalid> - 2017-08-09 14:51 +0100
      Re: why the ! operator can be used to determine a string is null? Jon Ribbens <jon+usenet@unequivocal.eu> - 2017-08-09 11:01 +0000
        Re: why the ! operator can be used to determine a string is null? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-08-09 16:17 +0200
          Re: why the ! operator can be used to determine a string is null? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-08-09 16:14 +0100
            Re: why the ! operator can be used to determine a string is null? Julio Di Egidio <julio@diegidio.name> - 2017-08-09 10:25 -0700
              Re: why the ! operator can be used to determine a string is null? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-08-09 21:04 +0100
                Re: why the ! operator can be used to determine a string is null? Julio Di Egidio <julio@diegidio.name> - 2017-08-09 13:11 -0700
                  Re: why the ! operator can be used to determine a string is null? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-08-10 00:59 +0100
                    [ANN] Spam filter for Google Groups (was: why the ! operator can be used to determine a string is null?) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-10 05:06 +0200
                      Re: [ANN] Spam filter for Google Groups (was: why the ! operator can be used to determine a string is null?) Julio Di Egidio <julio@diegidio.name> - 2017-08-10 01:00 -0700
                        Re: [ANN] Spam filter for Google Groups (was: why the ! operator can be used to determine a string is null?) John G Harris <niam@jghnorth.org.uk.invalid> - 2017-08-10 09:40 +0100
                    Re: why the ! operator can be used to determine a string is null? Julio Di Egidio <julio@diegidio.name> - 2017-08-10 00:56 -0700
            Re: why the ! operator can be used to determine a string is null? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-08-09 22:01 +0200
              Re: why the ! operator can be used to determine a string is null? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-08-09 23:35 +0100
                Re: why the ! operator can be used to determine a string is null? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-08-10 10:05 +0200
                  Re: why the ! operator can be used to determine a string is null? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-08-10 15:08 +0100
                    Re: why the ! operator can be used to determine a string is null? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-08-10 16:42 +0200
            Re: why the ! operator can be used to determine a string is null? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-09 23:56 +0200
              Re: why the ! operator can be used to determine a string is null? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-08-10 01:40 +0100
                Re: why the ! operator can be used to determine a string is null? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-10 03:44 +0200
                  Re: why the ! operator can be used to determine a string is null? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-08-10 03:20 +0100
                    Re: why the ! operator can be used to determine a string is null? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-10 04:33 +0200
                      Re: why the ! operator can be used to determine a string is null? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-08-10 03:57 +0100
    Re: why the ! operator can be used to determine a string is null? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-08 23:20 +0200
      Re: why the ! operator can be used to determine a string is null? Julio Di Egidio <julio@diegidio.name> - 2017-08-08 21:20 -0700
        Re: why the ! operator can be used to determine a string is null? Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-08-09 09:26 +0200
          Re: why the ! operator can be used to determine a string is null? Julio Di Egidio <julio@diegidio.name> - 2017-08-09 01:31 -0700
          Re: why the ! operator can be used to determine a string is null? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-09 11:32 +0200
            Re: why the ! operator can be used to determine a string is null? Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-08-10 09:10 +0200
              Re: why the ! operator can be used to determine a string is null? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-10 14:51 +0200
                Re: why the ! operator can be used to determine a string is null? Tim Streater <timstreater@greenbee.net> - 2017-08-10 15:11 +0100
                Re: why the ! operator can be used to determine a string is null? Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-08-10 18:52 +0200

Page 1 of 2  [1] 2  Next page →


#33714 — why the ! operator can be used to determine a string is null?

FromXue Feng <xf.lotus@yahoo.com>
Date2017-08-08 23:43 +0800
Subjectwhy the ! operator can be used to determine a string is null?
Message-ID<omcm6a$rga$1@gioia.aioe.org>
Hi all,
    I got an idea by a book that the code can be written as following:
	var ans = prompt("Enter a number: ");
	if (!ans)
		throw ...
to check whether the 'ans' get a null.
    I don't understand why the ! operator can do this. thanks.

[toc] | [next] | [standalone]


#33716

FromRobert Heller <heller@deepsoft.com>
Date2017-08-08 11:16 -0500
Message-ID<j6GdnWKTHu5rfhTEnZ2dnUU7-TnNnZ2d@giganews.com>
In reply to#33714
From the World of K&R C (where many of javascript's features originated
from, way back in the dark ages, before the bool[ean] type):

false is 0, true is anything not 0
NULL is 0, any valid pointer is not 0 (well, this is presumed, assuming
nominally valid code -- eg a function said to return a pointer will either a 
valid pointer or NULL).
!false is true
!true is false
!<any non-0 value> [true] is 0 [false]
!NULL is not NULL
!<non-NULL pointer> is 0 == NULL.


At Tue, 8 Aug 2017 23:43:28 +0800 Xue Feng <xf.lotus@yahoo.com> wrote:

> 
> Hi all,
>     I got an idea by a book that the code can be written as following:
> 	var ans = prompt("Enter a number: ");
> 	if (!ans)
> 		throw ...
> to check whether the 'ans' get a null.
>     I don't understand why the ! operator can do this. thanks.
> 
>                                                             

-- 
Robert Heller             -- 978-544-6933
Deepwoods Software        -- Custom Software Services
http://www.deepsoft.com/  -- Linux Administration Services
heller@deepsoft.com       -- Webhosting Services
                                

[toc] | [prev] | [next] | [standalone]


#33717

FromJon Ribbens <jon+usenet@unequivocal.eu>
Date2017-08-08 17:40 +0000
Message-ID<slrnooju52.303.jon+usenet@sable.unequivocal.eu>
In reply to#33714
On 2017-08-08, Stefan Ram <ram@zedat.fu-berlin.de> wrote:
> Xue Feng <xf.lotus@yahoo.com> writes:
>>var ans = prompt("Enter a number: ");
>>if (!ans)
>
>   It is possibly because it pleased Brendan Eich to define
>   JavaScript this way, possibly inspired by prior art (as
>   in the language C for example).
>
>   The result of »prompt« is a string containing the text
>   entered by the user, or »null«. If the user clicks OK
>   without entering any text, an empty string is returned.
>   If the user clicks the Cancel button, it returns null.
>
>   The operator »!« will convert its argument to Boolean,
>   and then yield »true« if the result of the conversion
>   was »false«, and vice versa.
>
>   The conversion of »null« to Boolean is »false«.
>
>   »!« is not required to determine whether a string is
>   »null«, other »Boolean contexts« can be used too because
>   they will also convert »null« to »false«.

I think you kinda missed out the most important bit there,
which is that the empty string is false in a boolean
context, and any other string is true.

[toc] | [prev] | [next] | [standalone]


#33722

FromJulio Di Egidio <julio@diegidio.name>
Date2017-08-08 21:38 -0700
Message-ID<31cc7ff5-d8ad-4dd6-a22b-5bdbbc36a054@googlegroups.com>
In reply to#33717
On Tuesday, August 8, 2017 at 7:45:17 PM UTC+2, Jon Ribbens wrote:
> On 2017-08-08, Stefan Ram <ram@zedat.fu-berlin.de> wrote:
> > Xue Feng <xf.lotus@yahoo.com> writes:
> >>var ans = prompt("Enter a number: ");
> >>if (!ans)
> >
> >   It is possibly because it pleased Brendan Eich to define
> >   JavaScript this way, possibly inspired by prior art (as
> >   in the language C for example).
> >
> >   The result of »prompt« is a string containing the text
> >   entered by the user, or »null«. If the user clicks OK
> >   without entering any text, an empty string is returned.
> >   If the user clicks the Cancel button, it returns null.
> >
> >   The operator »!« will convert its argument to Boolean,
> >   and then yield »true« if the result of the conversion
> >   was »false«, and vice versa.
> >
> >   The conversion of »null« to Boolean is »false«.
> >
> >   »!« is not required to determine whether a string is
> >   »null«, other »Boolean contexts« can be used too because
> >   they will also convert »null« to »false«.
> 
> I think you kinda missed out the most important bit there,
> which is that the empty string is false in a boolean
> context, and any other string is true.

He's kinda missed that he does not know shit about JS or programming in
general, and not even about CS at that point: typical computer science
"experts", yet not surprisingly as that's what people are taught nowadays,
to observe and conform, to the massive bullshit, the ugliest speculations,
and the flat EEG's...  Anyway, the so called software crisis is just yet
another sign of our demented times.

Julio

[toc] | [prev] | [next] | [standalone]


#33727

FromJohn G Harris <niam@jghnorth.org.uk.invalid>
Date2017-08-09 14:51 +0100
Message-ID<un4moc10er603uieo54748rkpi6v56v9ic@4ax.com>
In reply to#33722
On Tue, 8 Aug 2017 21:38:43 -0700 (PDT), Julio Di Egidio
<julio@diegidio.name> wrote:


  <snip>
>He's kinda missed that he does not know shit about JS or programming in
>general, and not even about CS at that point: typical computer science
>"experts",

Here you condemn someone for saying something, then later on praise
someone else for saying the same thing.

What should we call people who are inconsistent ?

  John

[toc] | [prev] | [next] | [standalone]


#33726

FromJon Ribbens <jon+usenet@unequivocal.eu>
Date2017-08-09 11:01 +0000
Message-ID<slrnoolr4r.303.jon+usenet@sable.unequivocal.eu>
In reply to#33717
On 2017-08-08, Stefan Ram <ram@zedat.fu-berlin.de> wrote:
> Jon Ribbens <jon+usenet@unequivocal.eu> writes:
>>On 2017-08-08, Stefan Ram <ram@zedat.fu-berlin.de> wrote:
>>>The conversion of »null« to Boolean is »false«.
>>I think you kinda missed out the most important bit there,
>>which is that the empty string is false in a boolean
>>context, and any other string is true.
>
>   You are right insofar as I indeed should have mentioned this.
>
>   But I was primed by the
>
> Subject: why the ! operator can be used to determine a string is null?
>
>   which explicitly asked for the case of »null«.

Unfortunately people tend to be very imprecise as to the meaning of
the phrase "null string", and may variously mean either the actual
null value or an empty string.

[toc] | [prev] | [next] | [standalone]


#33729

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2017-08-09 16:17 +0200
Message-ID<XnsA7CCA5CE3CA47eejj99@194.109.6.166>
In reply to#33726
Jon Ribbens <jon+usenet@unequivocal.eu> wrote on 09 Aug 2017 in 
comp.lang.javascript:

> Unfortunately people tend to be very imprecise as to the meaning of
> the phrase "null string", and may variously mean either the actual
> null value or an empty string.

Indeed, 
a string is NEVER null, 
because then it is NOT a string.

However, 
a variable which you intend to contain a string,
can be null,
but thren that is an object, not a string.

'use strict';
let myString;
alert(myString === undefined); // true
alert(myString === null); // false
alert(myString === ''); // false
alert(typeof myString); // undefined

myString = null;
alert(myString === undefined); // false
alert(myString === null); // true
alert(myString === ''); // false
alert(typeof myString); // object

myString = "";
alert(myString === undefined); // false
alert(myString === null); // false
alert(myString === ''); // true
alert(typeof myString); // string *****


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#33730

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2017-08-09 16:14 +0100
Message-ID<87zib8g4eb.fsf@bsb.me.uk>
In reply to#33729
"Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:

> Jon Ribbens <jon+usenet@unequivocal.eu> wrote on 09 Aug 2017 in 
> comp.lang.javascript:
>
>> Unfortunately people tend to be very imprecise as to the meaning of
>> the phrase "null string", and may variously mean either the actual
>> null value or an empty string.
>
> Indeed, 
> a string is NEVER null, 
> because then it is NOT a string.

Further complicated by the fact that there is a character called null
(sometimes Null, Nul or NULL) so a string can "be null" in that it
contains just that character.  It's not a clear way to speak about such
things but we're all guilty of using short-hands now and again.

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#33733

FromJulio Di Egidio <julio@diegidio.name>
Date2017-08-09 10:25 -0700
Message-ID<873e9645-1173-403d-bf7f-08ddcb17c057@googlegroups.com>
In reply to#33730
On Wednesday, August 9, 2017 at 5:14:14 PM UTC+2, Ben Bacarisse wrote:
> "Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:
> > Jon Ribbens <jon+usenet@unequivocal.eu> wrote on 09 Aug 2017 in 
> > comp.lang.javascript:
> >
> >> Unfortunately people tend to be very imprecise as to the meaning of
> >> the phrase "null string", and may variously mean either the actual
> >> null value or an empty string.
> >
> > Indeed, 
> > a string is NEVER null, 
> > because then it is NOT a string.
> 
> Further complicated by the fact that there is a character called null
> (sometimes Null, Nul or NULL) so a string can "be null" in that it
> contains just that character.

Nope, no programmer would call that a null string: that would be *empty*
in languages where the NUL character is a terminator, not in JS anyway:

<https://stackoverflow.com/a/13698720>

> It's not a clear way to speak about such
> things but we're all guilty of using short-hands now and again.

Speak for yourself, and RTFM.

Julio

[toc] | [prev] | [next] | [standalone]


#33738

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2017-08-09 21:04 +0100
Message-ID<87bmnofqyu.fsf@bsb.me.uk>
In reply to#33733
Julio Di Egidio <julio@diegidio.name> writes:

> On Wednesday, August 9, 2017 at 5:14:14 PM UTC+2, Ben Bacarisse wrote:
>> "Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:
>> > Jon Ribbens <jon+usenet@unequivocal.eu> wrote on 09 Aug 2017 in 
>> > comp.lang.javascript:
>> >
>> >> Unfortunately people tend to be very imprecise as to the meaning of
>> >> the phrase "null string", and may variously mean either the actual
>> >> null value or an empty string.
>> >
>> > Indeed, 
>> > a string is NEVER null, 
>> > because then it is NOT a string.
>> 
>> Further complicated by the fact that there is a character called null
>> (sometimes Null, Nul or NULL) so a string can "be null" in that it
>> contains just that character.
>
> Nope, no programmer would call that a null string: that would be *empty*
> in languages where the NUL character is a terminator, not in JS anyway:
>
> <https://stackoverflow.com/a/13698720>

I'm not sure what the purpose of the link is other than to delay by one
post your insulting and then pretending to plonk me.

Obviously it's not a null string but it is a string with just a null.
In a language with no character type (like ECMAScript), strings of
length one are often used for the same sort of purpose so what we both
note is an incorrect use of the term is not unlikely to occur.

>> It's not a clear way to speak about such
>> things but we're all guilty of using short-hands now and again.
>
> Speak for yourself, and RTFM.

He says, using a shorthand! :-)

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#33739

FromJulio Di Egidio <julio@diegidio.name>
Date2017-08-09 13:11 -0700
Message-ID<74abab16-a893-4724-832b-c108adccb51e@googlegroups.com>
In reply to#33738
On Wednesday, August 9, 2017 at 10:04:17 PM UTC+2, Ben Bacarisse wrote:
> Julio Di Egidio <julio@diegidio.name> writes:
> > On Wednesday, August 9, 2017 at 5:14:14 PM UTC+2, Ben Bacarisse wrote:
> >> "Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:
> >> > Jon Ribbens <jon+usenet@unequivocal.eu> wrote on 09 Aug 2017 in 
> >> > comp.lang.javascript:
> >> >
> >> >> Unfortunately people tend to be very imprecise as to the meaning of
> >> >> the phrase "null string", and may variously mean either the actual
> >> >> null value or an empty string.
> >> >
> >> > Indeed, 
> >> > a string is NEVER null, 
> >> > because then it is NOT a string.
> >> 
> >> Further complicated by the fact that there is a character called null
> >> (sometimes Null, Nul or NULL) so a string can "be null" in that it
> >> contains just that character.
> >
> > Nope, no programmer would call that a null string: that would be *empty*
> > in languages where the NUL character is a terminator, not in JS anyway:
> >
> > <https://stackoverflow.com/a/13698720>
> 
> I'm not sure what the purpose of the link is other than to delay by one
> post your insulting and then pretending to plonk me.

Self-fulfilling prophecies.

> Obviously it's not a null string but it is a string with just a null.
> In a language with no character type (like ECMAScript), strings of
> length one are often used for the same sort of purpose so what we both
> note is an incorrect use of the term is not unlikely to occur.

The only thing I note is that you keep talking bullshit.

> >> It's not a clear way to speak about such
> >> things but we're all guilty of using short-hands now and again.
> >
> > Speak for yourself, and RTFM.
> 
> He says, using a shorthand! :-)

*Plonk*

Julio

[toc] | [prev] | [next] | [standalone]


#33745

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2017-08-10 00:59 +0100
Message-ID<87d184e1iu.fsf@bsb.me.uk>
In reply to#33739
Julio Di Egidio <julio@diegidio.name> writes:
<snip>

> *Plonk*

When might you get round to doing this?  I'd be grateful if it were
sooner rather than later.  You've said it several times now.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#33752 — [ANN] Spam filter for Google Groups (was: why the ! operator can be used to determine a string is null?)

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2017-08-10 05:06 +0200
Subject[ANN] Spam filter for Google Groups (was: why the ! operator can be used to determine a string is null?)
Message-ID<4309688.GXAFRqVoOG@PointedEars.de>
In reply to#33745
Ben Bacarisse wrote:

> Julio Di Egidio <julio@diegidio.name> writes:
>> *Plonk*
> 
> When might you get round to doing this?  I'd be grateful if it were
> sooner rather than later.  You've said it several times now.

I think you are expecting too much from him.  You see, he is *trolling* here 
using the technically flawed *Google Groups* Web interface to Usenet.  As 
Google Groups has no built-in killfile, for him to have a killfile that 
works with the *current* version Google Groups, he would need to write one.  
And for that he would need to know what he is talking about, which is 
evidently not the case.

However, I have written and recently published as free software (licensed 
under GPLv3+) a customizable spam filter for Google Groups that could be 
adapted to be used as a killfile/scorefile:

<https://github.com/PointedEars/userscripts>
<https://github.com/PointedEars/userscripts/raw/master/ggSpamFilter.user.js>

[Tested with Tampermonkey 4.3.6 in Chromium 57.0.2987.98 on Debian GNU/Linux 
8.7 stretch/sid (64-bit).]

HTH ;-)

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#33755 — Re: [ANN] Spam filter for Google Groups (was: why the ! operator can be used to determine a string is null?)

FromJulio Di Egidio <julio@diegidio.name>
Date2017-08-10 01:00 -0700
SubjectRe: [ANN] Spam filter for Google Groups (was: why the ! operator can be used to determine a string is null?)
Message-ID<17a5e74e-7034-4254-8ccd-ff18d3b0f8f5@googlegroups.com>
In reply to#33752
On Thursday, August 10, 2017 at 5:06:23 AM UTC+2, Thomas 'PointedEars' Lahn wrote:
> Ben Bacarisse wrote:
> > Julio Di Egidio <julio@diegidio.name> writes:
> >> *Plonk*
> > 
> > When might you get round to doing this?  I'd be grateful if it were
> > sooner rather than later.  You've said it several times now.
> 
> I think you are expecting too much from him.  You see, he is *trolling*

Nah, it's just that you too are just full of shit...

*Plonk*

Julio

[toc] | [prev] | [next] | [standalone]


#33757 — Re: [ANN] Spam filter for Google Groups (was: why the ! operator can be used to determine a string is null?)

FromJohn G Harris <niam@jghnorth.org.uk.invalid>
Date2017-08-10 09:40 +0100
SubjectRe: [ANN] Spam filter for Google Groups (was: why the ! operator can be used to determine a string is null?)
Message-ID<ju6ooctmil7n3qe7koqiun1ma33s0v944e@4ax.com>
In reply to#33755
On Thu, 10 Aug 2017 01:00:28 -0700 (PDT), Julio Di Egidio
<julio@diegidio.name> wrote:

  <snip>
>*Plonk*
>
>Julio

This confirms it. You really are a plonker.

  John

[toc] | [prev] | [next] | [standalone]


#33754

FromJulio Di Egidio <julio@diegidio.name>
Date2017-08-10 00:56 -0700
Message-ID<1b4e5ab5-445e-44dc-bbc1-77792f1a3f68@googlegroups.com>
In reply to#33745
On Thursday, August 10, 2017 at 1:59:14 AM UTC+2, Ben Bacarisse wrote:
> Julio Di Egidio <julio@diegidio.name> writes:
> <snip>
> 
> > *Plonk*
> 
> When might you get round to doing this?  I'd be grateful if it were
> sooner rather than later.  You've said it several times now.

Yet it's you who keep attacking me, you retarded moron but also lying piece
of shit: and you'll keep getting back what you deserve, you incompetent
lying piece of shit.

BTW, I have also already explained to you and some other retards here that
plonking is not the same as kill-filing is not te same as an EOD: fucking
retarded pieces of shit, the less you know...

*Plonk*

Julio

[toc] | [prev] | [next] | [standalone]


#33737

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2017-08-09 22:01 +0200
Message-ID<XnsA7CCE017B2F9eejj99@194.109.6.166>
In reply to#33730
Ben Bacarisse <ben.usenet@bsb.me.uk> wrote on 09 Aug 2017 in 
comp.lang.javascript:

> "Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:
> 
>> Jon Ribbens <jon+usenet@unequivocal.eu> wrote on 09 Aug 2017 in 
>> comp.lang.javascript:
>>
>>> Unfortunately people tend to be very imprecise as to the meaning of
>>> the phrase "null string", and may variously mean either the actual
>>> null value or an empty string.
>>
>> Indeed, 
>> a string is NEVER null, 
>> because then it is NOT a string.
> 
> Further complicated by the fact that there is a character called null
> (sometimes Null, Nul or NULL) so a string can "be null" in that it
> contains just that character.  It's not a clear way to speak about such
> things but we're all guilty of using short-hands now and again.

Not true.

Whoever "speaks" in code anyway?

let myString = null;

...is not a character, not is it the number zero.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#33743

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2017-08-09 23:35 +0100
Message-ID<87zib8e5dl.fsf@bsb.me.uk>
In reply to#33737
"Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> wrote on 09 Aug 2017 in 
> comp.lang.javascript:
>
>> "Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:
>> 
>>> Jon Ribbens <jon+usenet@unequivocal.eu> wrote on 09 Aug 2017 in 
>>> comp.lang.javascript:
>>>
>>>> Unfortunately people tend to be very imprecise as to the meaning of
>>>> the phrase "null string", and may variously mean either the actual
>>>> null value or an empty string.
>>>
>>> Indeed, 
>>> a string is NEVER null, 
>>> because then it is NOT a string.
>> 
>> Further complicated by the fact that there is a character called null
>> (sometimes Null, Nul or NULL) so a string can "be null" in that it
>> contains just that character.  It's not a clear way to speak about such
>> things but we're all guilty of using short-hands now and again.
>
> Not true.
>
> Whoever "speaks" in code anyway?

No one.  I said a "way to speak about such things".

> let myString = null;
>
> ...is not a character, not is it the number zero.

Of course not.  I was talking about a string with a single NULL
character in it (was the not clear?).  For example:

  let myString = "\u0000";

Note that all I am saying is that the presence of a character called
NULL (or null, etc.) complicates things even more, and leads some (bad,
very bad!) people to use incorrect language.

I get the feeling this is contentious because I've said it, rather than
there being any real disagreement.  People might, in an off-hand sort of
way say "here is is a question-mark: var s = '?';" and they might also
so say "here is a null: var s = '\0';".  Of course they are very, very
wrong to even think of saying that, but to suggest that they might is
not outrageous, much less to say that doing so would add to the
confusion already noted.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#33756

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2017-08-10 10:05 +0200
Message-ID<XnsA7CD66B0DE917eejj99@194.109.6.166>
In reply to#33743
Ben Bacarisse <ben.usenet@bsb.me.uk> wrote on 10 Aug 2017 in 
comp.lang.javascript:

> Of course not.  I was talking about a string with a single NULL
> character in it (was the not clear?).  

Indeed, you were.

But that does not change the meaning of a null-string,
which in Javascript does not exist,
since the value of a variable being null is an object, 
not a string.

I doubt that there is a "null-character" anyway,
as it forgoes on the idea of a character in the same way.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#33759

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2017-08-10 15:08 +0100
Message-ID<87efsjcy6v.fsf@bsb.me.uk>
In reply to#33756
"Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> wrote on 10 Aug 2017 in 
> comp.lang.javascript:
>
>> Of course not.  I was talking about a string with a single NULL
>> character in it (was the not clear?).  
>
> Indeed, you were.
>
> But that does not change the meaning of a null-string,
> which in Javascript does not exist,
> since the value of a variable being null is an object, 
> not a string.

Of course not.  No one has argued otherwise.  All I said was that the
presence of yet another meaning for the word "null" adds to the
confusion (for some people).

> I doubt that there is a "null-character" anyway,
> as it forgoes on the idea of a character in the same way.

Unicode uses the term "character" for all sorts of things you might not
consider characters.  NULL is only one of these peculiar creatures.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.javascript


csiph-web