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


Groups > comp.lang.javascript > #30609

Re: not "autovivification", but ...?

Path csiph.com!weretis.net!feeder4.news.weretis.net!news.albasani.net!.POSTED!not-for-mail
From Stefan Weiss <krewecherl@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: not "autovivification", but ...?
Date Thu, 2 Jun 2016 13:20:28 +0200
Organization albasani.net
Lines 46
Message-ID <nip4ps$vhs$1@news.albasani.net> (permalink)
References <autovivification-20160531121607@ram.dialup.fu-berlin.de> <nik0k5$8mu$1@news.albasani.net> <1dc7bd11-343d-4cbb-b75d-1db8516666a0@googlegroups.com> <nin783$9qu$1@news.albasani.net> <d7cf47ca-3871-46e0-8434-b17ec1fe1440@googlegroups.com> <ninr5k$gee$1@news.albasani.net> <6429329.X1ROTxqqWj@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace news.albasani.net 2vkxzoyN8xckJi3cyTv4kpb2CzfGptW6pLVQmgznHMu95A2tEc4gpvRSyRvRdhKIdS+h8deTyYJCDp8ySbixfw==
NNTP-Posting-Date Thu, 2 Jun 2016 11:20:28 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="VqnXJS+81X75c3NnEkcvbzSMNtEN611aZwJOSf4cQfuokCwQdwSbmdtXbMhbl745V5opg/sUchu6+dpb91b3jL5KbG2xr+zcmLdPDpaPCvGyCuPtMIZQMvl5oaZBhylW"; mail-complaints-to="abuse@albasani.net"
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0
In-Reply-To <6429329.X1ROTxqqWj@PointedEars.de>
Cancel-Lock sha1:Y/7Nue52yUybjcEw2H/RAAICB3o=
Xref csiph.com comp.lang.javascript:30609

Show key headers only | View raw


Thomas 'PointedEars' Lahn wrote:
> F'up2 comp.lang.php

I don't read comp.lang.php. If you really want to talk about an off-topic
remark, do it here.

> Stefan Weiss wrote:
> 
>> PS, a little off-topic: PHP is probably the worst language to work with in
>> this regard. It will happily allow implicit multi-level creation in arrays
>> -
>>
>>    // ($foo is unused up to this point)
>>    $foo["bar"][13]["baz"] = "qux";
> 
> This is so very useful. (No sarcasm.)

Useful, maybe. It's also more dangerous, because it won't warn you about a
typo in one of the keys; PHP will silently build up a parallel structure if
you mistype "bar". I would rather get the early warnings.

>> - but will emit E_NOTICE (a type of error)
> 
> A common misonception.  It is a kind of debug message instead and can be 
> suppressed in various ways.

E_NOTICE is not just emitted for undefined array keys or indices. If you
disable or suppress it, you will no longer be warned about mistyped variable
names, among other things. It's an important tool, and should enabled during
development.

> if you write
> 
>   @$foo["x"]
> 
> the notice will go away without any extra configuration.

And so will the more serious errors. The @ operator suppresses ALL
recoverable errors, not just notices. @$fooo["x"] or @$foo[x] will not
trigger any warnings.

(The @ operator also used to produce a noticable performance overhead in
earlier versions, but this is now negligible.)


- stefan

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: not "autovivification", but ...? Stefan Weiss <krewecherl@gmail.com> - 2016-05-31 14:38 +0200
  Re: not "autovivification", but ...? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-01 08:03 -0700
    Re: not "autovivification", but ...? Stefan Weiss <krewecherl@gmail.com> - 2016-06-01 19:49 +0200
      Re: not "autovivification", but ...? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-01 14:29 -0700
        Re: not "autovivification", but ...? Stefan Weiss <krewecherl@gmail.com> - 2016-06-02 01:29 +0200
          Re: not "autovivification", but ...? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-02 02:16 +0200
            Re: not "autovivification", but ...? Stefan Weiss <krewecherl@gmail.com> - 2016-06-02 13:20 +0200
          Re: not "autovivification", but ...? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-02 15:51 -0700

csiph-web