Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105947 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 26075 invoked from network); 16 Jun 2019 02:50:38 -0000 Received: from unknown (HELO mail-pl1-f181.google.com) (209.85.214.181) by pb1.pair.com with SMTP; 16 Jun 2019 02:50:38 -0000 Received: by mail-pl1-f181.google.com with SMTP id k8so1593819plt.3 for ; Sat, 15 Jun 2019 17:04:24 -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=jDCSIyYTIDI9zq3tdgZxKs09/8pYL5GuWaAbgiFM6SE=; b=XdMVYmDi4AAiHOzTznyQ102UoSCmEJsH8dgMiMn5VicPkKlKwUSNNON+N24Dsmt/BQ Ip8tqACQzRGBoq4Nv2ww8/58cGGCjroyl4D7NsFVGDvrjwBjT2fodsabOUytJul7YefO o2BRoODwRmoTrw/XxRvPpxOWskE6qS3hA1ie4Y9chn8u/ok6EeFHoRgvB3YVsu/11PFf M0QPYqyTuY1bKfM7PPuOvPmrHhle86F3wfATc6jAttWcs3bjbCNUgVIJAj1YDXyntzBT l46fDQeNE9aWav7qGHtHwPEoThQxaYaUh6101YHPWjoUrxyTy/M6dFuHbApafSSs386B A7tg== X-Gm-Message-State: APjAAAVnJoOHyCVQyoAGBj0Wjru1d0KBcFQcVwm9stSQVTSqYhjySc/6 KUZw8WcW+2jQkyHNk3dxRA9ZFTjnqht5vyK2LWQ= X-Google-Smtp-Source: APXvYqyukR46ggfHuY6ft8sjRGxs4/6T0GhiQOWd9Z8Z5nrmgHYr5itOqgWtWoDoOQugPnO0AdyyV8uBnzGbldmocbs= X-Received: by 2002:a17:902:b70f:: with SMTP id d15mr18806043pls.318.1560643463684; Sat, 15 Jun 2019 17:04:23 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 16 Jun 2019 03:04:12 +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. 02.48 skrev Wes : > > Hi Kalle. I hope it's feasible. Unfortunately I don't know much about > internals. Any info on the matter would be very appreciated, though :P > > Anyway, if we can scan the function body to complain about `return null;` > when the function is `:void`, surely we can scan just the very top of the > function body to read the imports :P The latter is detected at a different stage, we can detect some type errors during the language parser phase, for your example if the prototype of the function/method has a return type set to void, then any return statements within the body causes an error, while most other errors happens at runtime: function invalid() : string { return null; } Will first throw an error the moment it is called, not when it is parsed unlike your example. The problem here is that you cannot perform that binding of a variable until the runtime kicks in (you don't know if $a exists until you attempt at binding it which must be at the time the closure is created, not when executed from an engine perspective). (Also, regarding the other email you sent to Moe, please keep this language and such comments off the list and in private, such does not belong to internals, it is a mailing list about the development of a programming language, not a kinder garden) --=20 regards, Kalle Sommer Nielsen kalle@php.net