Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105941 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 3108 invoked from network); 16 Jun 2019 01:08:35 -0000 Received: from unknown (HELO mail-pf1-f170.google.com) (209.85.210.170) by pb1.pair.com with SMTP; 16 Jun 2019 01:08:35 -0000 Received: by mail-pf1-f170.google.com with SMTP id m30so3540782pff.8 for ; Sat, 15 Jun 2019 15:22:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=kRpM9WLI4qSp5iUVT3zJUS6rhgLzji8VSeLLeCPiERQ=; b=ofK0CafSE1Nlh3xcXFd2gtvP7y5AMNN2tWx0ka2ed/m2nhUL8cqeR2Y1z8kwe7RrM+ Wgg9kxO+auGehZdSFhNhdL0gf9YtiN4C9EfpLH6XJasVwzbPbCcxcTLOX7kmzKAT9duu LvfE2rCeKZCemlW6zDKb4oJ9cdV8s8UAAA4nSMWlbJjmvxzaTFtgb7VhR8KGPUKG05F7 BfEKSMtrAjdPj2IbNEgCdfAc1Gmy4puS5EhivDWJ9HYBznPFMDWslLW0dTnDmdIS9/j5 ksDDtbVOnPJ2CXG7X/wM/nu6OZHPbWdRkrOe1E/lipZRp7JoRP4Dia5n4bY0hseTjwQf Jzfg== X-Gm-Message-State: APjAAAWINOdl/RXg39a2f09NT53ubMoZvoxdUTo6oXNDd7CdFirXTS65 hnsAmoRnrTXQz4LNtHQupXg/n+NqISi7D2TbKMc/FgT+ X-Google-Smtp-Source: APXvYqxELEwozC+lX0tDkBT6fs4p45hBKyc5YXa1rI4Bnr3pu39GSwWsgG+2JtNAS/yorLtIlHJzukibFKO2eMdmZpw= X-Received: by 2002:a17:90a:d817:: with SMTP id a23mr17810835pjv.54.1560637339580; Sat, 15 Jun 2019 15:22:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 16 Jun 2019 01:22:07 +0300 Message-ID: To: Wes Cc: Marco Pivetta , PHP Internals List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV][RFC] Alternative "use" syntax for Closures From: kalle@php.net (Kalle Sommer Nielsen) Den s=C3=B8n. 16. jun. 2019 kl. 01.09 skrev Wes : > > Declaring variables or specifying which ones to import. Essentially it's > the same thing, so what gives? It's PHP's syntax, IMHO, that makes the > thing irritating to write :D The proposed syntax was also that of the proposed syntax when closures arrived in 5.3 (and back then it was using the then keyword 'lexical'), anyway. I believe the current syntax was chosen due to scopes, as values are bound specifically when the closure is created and not when the closure is executed. For example if you have a function that returns a closure and the closure imports a variable local to that and then later call it from a different scope, that means we need to keep that old scope alive until then which can be rather problematic, instead it was decided back then to have the import of parent scope variables as apart of the prototype as it is possible to capture the value in the Engine at this point in time. I agree its odd but I would much rather keep the current implementation. Also in regards to the RFC, if you have massive argument lists like in the RFC then I think you should re-think your design and put such complex computations into separate methods which also encourages better testability. --=20 regards, Kalle Sommer Nielsen kalle@php.net