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


Groups > comp.lang.php > #16754 > unrolled thread

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

Started byThomas 'PointedEars' Lahn <PointedEars@web.de>
First post2016-06-02 02:16 +0200
Last post2016-06-04 16:24 +0200
Articles 4 — 2 participants

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: not "autovivification", but ...? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-02 02:16 +0200
    Re: not "autovivification", but ...? "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-06-02 11:47 +0200
      Re: not "autovivification", but ...? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-03 22:20 +0200
        Re: not "autovivification", but ...? "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-06-04 16:24 +0200

#16754 — Re: not "autovivification", but ...?

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2016-06-02 02:16 +0200
SubjectRe: not "autovivification", but ...?
Message-ID<6429329.X1ROTxqqWj@PointedEars.de>
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.)
 
> - 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.

> if we try to read a nonexistent index ($foo["x"]).
                                  ^^^^^
The proper term is _key_, and if you write

  @$foo["x"]

the notice will go away without any extra configuration.

F'up2 comp.lang.php

-- 
PointedEars (ZCE PHP)
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

[toc] | [next] | [standalone]


#16755

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2016-06-02 11:47 +0200
Message-ID<niovaj$a17$1@solani.org>
In reply to#16754
On 02.06.2016 at 02:16, Thomas 'PointedEars' Lahn wrote:

> 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.)
>  
>> - 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.
> 
>> if we try to read a nonexistent index ($foo["x"]).
>                                   ^^^^^
> The proper term is _key_, and if you write
> 
>   @$foo["x"]
> 
> the notice will go away without any extra configuration.

As well as all other notices, warnings, etc.  Not a problem in this
case, but consider:

  function keyName() {
      trigger_error('deprecated', E_USER_DEPRECATED);
      return 'x';
  }
  @$foo[keyName()];

-- 
Christoph M. Becker

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


#16756

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2016-06-03 22:20 +0200
Message-ID<4526211.5joGbGu2Zc@PointedEars.de>
In reply to#16755
Christoph M. Becker wrote:

> On 02.06.2016 at 02:16, Thomas 'PointedEars' Lahn wrote:
>> Stefan Weiss wrote:
>>> if we try to read a nonexistent index ($foo["x"]).
>>                                   ^^^^^
>> The proper term is _key_, and if you write
>> 
>>   @$foo["x"]
>> 
>> the notice will go away without any extra configuration.
> 
> As well as all other notices, warnings, etc.  Not a problem in this
> case, but consider:
> 
>   function keyName() {
>       trigger_error('deprecated', E_USER_DEPRECATED);
>       return 'x';
>   }
>   @$foo[keyName()];

Straw man (Stefan in cljs, *and* you, being more courteous than him, here 
where it belongs). 

I did not say it were the best solution.  I did not say it were a general 
solution.  I said it is *a* solution *without extra configuration*.

See also: <http://php.net/error_reporting>

-- 
PointedEars
Zend Certified PHP Engineer 
<http://www.zend.com/en/yellow-pages/ZEND024953> | Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.

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


#16757

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2016-06-04 16:24 +0200
Message-ID<niuo9s$hgn$1@solani.org>
In reply to#16756
On 03.06.2016 at 22:20, Thomas 'PointedEars' Lahn wrote:

> Christoph M. Becker wrote:
> 
>> As well as all other notices, warnings, etc.  Not a problem in this
>> case, but consider:
>>
>>   function keyName() {
>>       trigger_error('deprecated', E_USER_DEPRECATED);
>>       return 'x';
>>   }
>>   @$foo[keyName()];
> 
> Straw man (Stefan in cljs, *and* you, being more courteous than him, here 
> where it belongs). 
> 
> I did not say it were the best solution.  I did not say it were a general 
> solution.  I said it is *a* solution *without extra configuration*.

And I merely stated that this solution might have drawbacks in more
complex cases.  I understand that you already have been aware of these
dangers, but not necessarily other readers.

-- 
Christoph M. Becker

[toc] | [prev] | [standalone]


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


csiph-web