Hi! > <?php > 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 smalys...@gmail.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php