Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100172 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32345 invoked from network); 10 Aug 2017 21:21:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Aug 2017 21:21:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=andreas@dqxtech.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=andreas@dqxtech.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dqxtech.net from 209.85.218.48 cause and error) X-PHP-List-Original-Sender: andreas@dqxtech.net X-Host-Fingerprint: 209.85.218.48 mail-oi0-f48.google.com Received: from [209.85.218.48] ([209.85.218.48:34940] helo=mail-oi0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9C/E0-34801-16ECC895 for ; Thu, 10 Aug 2017 17:21:38 -0400 Received: by mail-oi0-f48.google.com with SMTP id e124so18573605oig.2 for ; Thu, 10 Aug 2017 14:21:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=sdWG9aT7Xt6EaanIZnwGQU3RYDkSnofA792YkAEGuks=; b=hVhX2Ty+iXVnAVSs4RakSZlDy5FEM1D9aOFIRx4vO44rfEDdGp9RTdbN7L9hImFig6 +MMflmMJGcRjprzX4wDbntAVsJF50NMVU2jL07c1z0/9/QLFxwppsI/woK+mClpc3nD/ EKxw7ixrJV+OHUklFHn0xRnYgPQL5lmfgFmcZFEBVwg1PeWTryn82PsXekncCycqsh/O PPbuxEkbZGPnyfbid9kU/rmO9QYyHKuiYaGYhNZ60eX2Cnvcw5/FqXrt7bLFD1EIwe9S 4BqZGDJhoQMTFJe2phakYKVfcK60BxUaYB4dYwJ3USkyyGvDQw1mLP+zbzMB39h5snfQ AnrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=sdWG9aT7Xt6EaanIZnwGQU3RYDkSnofA792YkAEGuks=; b=AYsHutac3gBS01T7LjYLp4gUN8nhreukwkqqPR44Cm0g02Ar13ZbTMJWI2d2HdQMPV WiiFYjHRoHWVFljTT/w69F0BevhUVWfiGJvyw/pW7jFxQjM6rV/DCJNN+xvEcPtftYsN lCf6JbYSAoU5dYC+rs5Fj2c4AROamPJocMvSbD8sgc2ljZHMmRez8KqU7FyP61LLYcJb YGremB/wrM/enwtayrN5mzHlN6BTj2QJXqFojLxluOhqRn2JPcm5AFNpCmmakXp2lrLk okFdy2chq9bzs8QLaZNY0dIkd25MaPC8vOXbig7Dy+OPsbLY6tTOD31ffavvJMtpuWDN xYBQ== X-Gm-Message-State: AHYfb5ioRcPi+8pnpNrN8W///anRbAqMeAQ+e9LRzyqNsutQKfdEYVTP Acy27ILPqGq3uCOBMuQ= X-Received: by 10.202.239.86 with SMTP id n83mr14786650oih.255.1502400094376; Thu, 10 Aug 2017 14:21:34 -0700 (PDT) Received: from mail-io0-f169.google.com (mail-io0-f169.google.com. [209.85.223.169]) by smtp.googlemail.com with ESMTPSA id c196sm7554649oib.43.2017.08.10.14.21.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Aug 2017 14:21:33 -0700 (PDT) Received: by mail-io0-f169.google.com with SMTP id m88so14098695iod.2 for ; Thu, 10 Aug 2017 14:21:33 -0700 (PDT) X-Received: by 10.107.202.133 with SMTP id a127mr11772593iog.54.1502400093386; Thu, 10 Aug 2017 14:21:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.44.34 with HTTP; Thu, 10 Aug 2017 14:21:12 -0700 (PDT) Date: Thu, 10 Aug 2017 23:21:12 +0200 X-Gmail-Original-Message-ID: Message-ID: To: PHP internals , reeze@php.net, danack@basereality.com, devnuhl@gmail.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Allow default value in list() syntax From: andreas@dqxtech.net (Andreas Hennings) Hello list, I found this RFC, describing a feature I wanted for a long time: https://wiki.php.net/rfc/list_default_value https://marc.info/?l=php-internals&m=144707619509724 (I don't know how to correctly reply to old emails that are not in my inbox, sorry for that. I don't like mailing lists.) I regularly want this kind of feature when unpacking a string with explode(): list($prefix, $suffix = NULL) = explode(':', $string); if (NULL !== $suffix) { ... } This is for situations where a string is coming from somewhere, we hope it has the format "aaa:bbb", but we cannot be sure. Sometimes I use a workaround like this: list($prefix, $suffix) = explode(':', $string . ':'); if ('' !== $suffix) { ... } Which works, but means a new string will be allocated in memory. I find the list() with default values to be a decent and understandable language feature. -- Andreas