Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106587 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 63188 invoked from network); 14 Aug 2019 12:20:34 -0000 Received: from unknown (HELO mail-wr1-f41.google.com) (209.85.221.41) by pb1.pair.com with SMTP; 14 Aug 2019 12:20:34 -0000 Received: by mail-wr1-f41.google.com with SMTP id g17so110470487wrr.5 for ; Wed, 14 Aug 2019 02:49:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=aw0IuNkXNrt7VeS7kdzhzZVf+0HyoXgtOExqnGtAyYU=; b=eUKGgsE1eIJCmoTjQXbETm9pfAnWHFpsyhbhIrKBwA/ERWIlKQlOtiG5y2wcJEY+4Z jzD5pp87n61MHTw5O5BVb5FmmEix9rYWyjghUT1NWc7wrj0hziTtQFcZQXWBUkHybyuo 8BkEmeb8zUHJDI5ISLxo1BX7Q1QTJk2N+3SIzPmKP3Om9ngLlWuCHjXW9OxXSlLzU+Zc CGdc7DdjXcGfPlI1i7baEdFj6ugNge9Gzm7R+gvtbFsHml7PktvhNymyiyNH2+oy6x/0 UyNaNm2K9cs2XpNSvk9IbhGHpjqkzCUgaUXAArJxTtPtWPlwAny1Q8iBXRC/lE7Y1P4C A9rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=aw0IuNkXNrt7VeS7kdzhzZVf+0HyoXgtOExqnGtAyYU=; b=juD38xm1qQixNKMd4xiDou4a1KwO7SSWKMWJwP0ojHUeSHlct7YVmnE0qnvYwLqLpi 9/MIbqJLJxbi6VqmEzmq6WS47WY4J+n7vqtT5JRsnZv2SxtNskzCGtSuCOLuk2hNquEE cadnE+qCLDQORpqwMQI9NyDdbXAtpeerEgOXT5xT3xeG2BfXi+UT5YVC2HwURv8J08Tv Ef86S6hN9alTO8vRdlyPytMDWvg0cnULSV3JsOs5DHfS2QuiNL4oi3sHnbwyqfiVMloi STVTpgHsAnuggtAI1WYLXNNi0EdY1MMmijN2uOtYadRPn6RN78iRpxyjYekE3WG8vRJ5 FhpA== X-Gm-Message-State: APjAAAVaG/dXSjSEfk62rqlXlAucrmYKva8kv94NKeavmFxYphjy4HUz 428bXnpOi20eOSA+ARKWUieZyWTV X-Google-Smtp-Source: APXvYqwcCNpxNOZ0T8vU1lGZChNLeE28oaHNIN8l5kp2/i8P/i74Qg1HTX41NezNBqzWo9yhulkldw== X-Received: by 2002:adf:c594:: with SMTP id m20mr55134384wrg.126.1565776150172; Wed, 14 Aug 2019 02:49:10 -0700 (PDT) Received: from [192.168.0.16] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.googlemail.com with ESMTPSA id a19sm51948102wra.2.2019.08.14.02.49.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Aug 2019 02:49:09 -0700 (PDT) To: internals@lists.php.net References: <25d774e8-183b-d39c-4ac4-81c1b7770229@gmail.com> <5d5298a5.1c69fb81.b4ed1.2d97SMTPIN_ADDED_MISSING@mx.google.com> <3db68c5e-54d1-812f-bbf5-1b089cba1bff@gmail.com> <5d52f72d.1c69fb81.8f95f.57a1SMTPIN_ADDED_MISSING@mx.google.com> <2bcb05d6-abf6-4fcb-599e-eaf4bcd58878@gmail.com> <182a6bd5-4057-7ba1-2cca-ab0be37e0b75@gmail.com> Message-ID: <72896017-20d0-16af-b188-8500777f947b@gmail.com> Date: Wed, 14 Aug 2019 10:49:07 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] Namespace-scoped declares, again From: rowan.collins@gmail.com (Rowan Collins) On 14/08/2019 10:27, MichaƂ Brzuchalski wrote: > But that's conflicting with you above idea for package definition like > that: > package MyVendorMyLibrary { > declare(strict_types = 1); > } That's not what I'm suggesting; perhaps my example could have been clearer. I envisage two new keywords: - To put some code in a package, you would write "package Foo;" at the top of a file, or "package Foo { }" around a block, in the same way you can do now for namespaces and declare() statements. - To define a package before it is used, you would write "packagedef Foo { }" around some block of pseudo-PHP that defined the options for that package. That might involve using declare() directly, or might just be an array that defines the options. > You suggest that it would trigger autoload to load "MyVendor\MyPackage" > but current autoload machinery is able to load only classes, > not even functions or consts! cause it gets the only class name now. > It would need to be changed anyway. As I said in another reply, this is only the same change that needed to be made to support "trait" alongside "class" and "interface", or would be needed to support "enum" or "struct". The userland part of the autoloader already doesn't know which of those it's looking for, so the only constraint is that the names can't collide, so you couldn't name a package the same thing as a class. There are other problems with autoloading functions and constants, but the relevant point is that you can define function foo() {} and class foo {} in the same namespace; as long as you couldn't also have a separate package foo{}, it could share the same autoloader as classes, interfaces, and traits. Regards, -- Rowan Collins [IMSoP]