Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94771 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10902 invoked from network); 1 Aug 2016 06:00:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Aug 2016 06:00:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.180 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.161.180 mail-yw0-f180.google.com Received: from [209.85.161.180] ([209.85.161.180:34511] helo=mail-yw0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E3/00-10435-D65EE975 for ; Mon, 01 Aug 2016 02:00:14 -0400 Received: by mail-yw0-f180.google.com with SMTP id z8so163764931ywa.1 for ; Sun, 31 Jul 2016 23:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=mRvrqZpIN7AVrIPV/bzWlkhxWZ7L/QX63q54DGL/iW0=; b=yCoZhPcGKvniYVJIsZbhyijviU/HtKhahPmFROreVss1Nx8hOvQ4i3HABHkdfDlT1k HC8vciPA7BjrWnj5HNCbr0Ckz3VSsRRogYZnb8n6VWn/zVtgPp/8Hk3M0TOOJk5DeDzP YbYg0PuUPtDBZ9Zhxn8MreGkWIcRxFXjy2V0PJUYm0cajRJ6saZRwjcjMCuYCKJ9JgY5 NY0B5nReEyRNPeNcapO5t1bsNRXi/YE+xmNdKqfO4AUJnNlZkoGEnBhNfEXfHLkF7XTR w/avSj09NFu99bPKB8oLA/4dQPOY2U0lQESDXPn9+UyTQhYMmlWJNvDRXQhAsR0HZsfg 1jDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=mRvrqZpIN7AVrIPV/bzWlkhxWZ7L/QX63q54DGL/iW0=; b=jXF0V3Ud3rG3xFd5zLzm9GTUrUkqbbZuNFWAUe04vzIYzHLGcczRco1qsSkjwN3Ky0 WgBt4xNMCg/KXjlLqKtcfRLJfIgnU8FGe9heS/lb7N4ScDhi87F7ZA+mlH5feSwja2V5 wfitdAt72UHkpzKl6ra3umfDM4TXOrS64zpruUaF4cqjVdfJUCb+z4xwGS2C/HH8DYEa yzBL8otiHIP1gv+Jo2hOCYzdTycOxrEe3SQ07fmJ2W1LW5BYjNomSPP3mlE5VFwUczqZ iJpd0qqmZZ4IQTZ8jjYjEzz0kkp7spqrs5Y1GquXTnRYTxtrtatmBUoqO8jY1TaWHRAY +nfg== X-Gm-Message-State: AEkooutfOXiDI8uUDYHR8jFWnRVTXw/S1uVlFdwI18rXoL0sUMrnp8c4iiKFpstjQJe++A== X-Received: by 10.37.55.214 with SMTP id e205mr35056475yba.10.1470031211032; Sun, 31 Jul 2016 23:00:11 -0700 (PDT) Received: from stas-air.attlocal.net (76-220-46-95.lightspeed.sntcca.sbcglobal.net. [76.220.46.95]) by smtp.gmail.com with ESMTPSA id u189sm11995155ywe.25.2016.07.31.23.00.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Jul 2016 23:00:10 -0700 (PDT) To: =?UTF-8?Q?Midori_Ko=c3=a7ak?= , PHP Internals References: Message-ID: <90fc8415-b251-cb8b-5511-c08d77653390@gmail.com> Date: Sun, 31 Jul 2016 23:00:09 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Structured Object Notation From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > use \Psr\Http\Message\ServerRequestInterface as Request; > use \Psr\Http\Message\ResponseInterface as Response; > > require '../vendor/autoload.php'; > > $app = new \Slim\App; > $app->get('/hello/{name}', function (Request $request, Response $response) { > $name = $request->getAttribute('name'); > $response->getBody()->write("Hello, $name"); > > return $response; > }); > $app->run(); > This causes loss of readability and benefits of oop in most of the > programs. Most of the programs we write, end up to have some piece of I don't see any loss of readability. Which part is not readable? > // Here comes the spaghetti > $app = new B("midori"); > $app->foo(1,2); > $app->bar(3,4); Don't see any spaghetti here. Are you using this term in some other meaning that is commonly used? > Instead of instantiating objects on the fly, here I propose a structured > definition of an object using this syntax: > > object $app instanceof B{ > $world = "midori"; > // allowed methods comes after method definition > // in the beginning state allowed methods are foo and bar > public function __construct($world){ > // if method body is implemented, > // parent class method run automatically > // object method runs after. > // This block runs $app = new B($world); > $this->foo(1,2); > }(foo, bar); > > // The only allowed method is bar in this state > public function foo(1,2)(bar); > > // if allowed methods are empty or not defined > // object is destructed > public function bar(3,4){ > }; > } Here we've got loss of readability. What is "}(foo, bar);" ? I have no idea. Let me parse it. foo and bar look in this context like constants, but I don't see any definitions. Maybe defined elsewhere? Fine. (foo, bar) looks like function invocation, taking these constants as parameters. But what is the function? Obviously something that precedes the (). So you are calling constructor with two arguments foo and bar? But constructor only accepts one argument! I'm lost now. Next: > public function foo(1,2)(bar); This looks like double function call - but why it happens in a definition of function? What is function foo? > public function bar(3,4){ > }; OK, this looks like function definition - curly braces and stuff. But why the arguments are 3,4? Confused again. Sorry, I think this is overly complicated way of doing something that we can already do in easy way that 100% of the users can understand. -- Stas Malyshev smalyshev@gmail.com