Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61848 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5346 invoked from network); 28 Jul 2012 06:12:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jul 2012 06:12:10 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.216.42 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.216.42 mail-qa0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:59240] helo=mail-qa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BE/52-23870-9B283105 for ; Sat, 28 Jul 2012 02:12:10 -0400 Received: by qafi31 with SMTP id i31so174268qaf.8 for ; Fri, 27 Jul 2012 23:12:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding:x-gm-message-state; bh=elyMSF2xfn3znvM8Oxx9HYlktiRBr6gIhNzovktNko8=; b=fn5YU+1VSnXDz3JkXxOb17rtrQH51wivYaF0MWFFNIIjYJIVIv8eNIH1Ns0Ycs7TbN uEsrdaM9UKu1EcL2q9B4REHNuH9hWAqVqiUs1ekFBzlEKBm7yg0nehx4qOlmdFjXXmmK 7H+AN/ppfS8T8ziiKICD6Kz7/5mrkJuzT3dv11AF1dInTnJiG1pJsGjOekbhjqb1lGHe 0I2Com+hw0HI52WHEcnEKlj7TBaXO/ZdG5XWq2KcLVK3fivswaKX+d07m6lOMwGHQqMX dvgl1Ti0UFzG650d5HawMulVLywXKLVZT6fH/EbUHz20U5xZGQJHre0tMB0PR8FIOKkV j9qg== Received: by 10.229.102.67 with SMTP id f3mr2197572qco.137.1343455927261; Fri, 27 Jul 2012 23:12:07 -0700 (PDT) Received: from [172.16.26.30] ([38.106.64.245]) by mx.google.com with ESMTPS id eb10sm3382279qab.4.2012.07.27.23.12.04 (version=SSLv3 cipher=OTHER); Fri, 27 Jul 2012 23:12:06 -0700 (PDT) Message-ID: <501382B3.2090702@lerdorf.com> Date: Fri, 27 Jul 2012 23:12:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Alex Aulbach CC: Sara Golemon , Andrew Faulds , Ferenc Kovacs , Sherif Ramadan , internals@lists.php.net References: <500EEA76.1030407@ajf.me> <5010138D.5050804@ajf.me> <501015B9.6050704@ajf.me> <501085FE.7070406@lerdorf.com> In-Reply-To: X-Enigmail-Version: 1.5a1pre Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQmG7eoN2V//baqT6qsiiCe/TalsWvVizO5ivl7MkIKxGp9kmfE7laM0PqWEOtsOC5wBjMCp Subject: Re: [PHP-DEV] Re: Generators in PHP From: rasmus@lerdorf.com (Rasmus Lerdorf) On 07/26/2012 11:36 PM, Alex Aulbach wrote: > 1) The bigger the language grows, the more we need to think about how > to implement new features. > I think it's a bad argument to say "we made this and that not so > ideal, so we can make this also. Don't be so idealistic." :) > I think it's a duty to make new things more logical and more > self-explaining and more fitting into the rest. Always, and the bigger > it is, the more it must be done. > > 2) We should do things better, if we can. > This opens two questions. First: Is a new keyword better than none, > second: can we? Both of these points essentially argue that naming the ordered maps "arrays" in PHP was somehow not ideal and we (well, I in this case) should have done better. I completely disagree. One of the strengths of PHP is that it scales. It scales up to the largest sites in the world while at the same time it scales down to weekend warriors. Doing both in the same codebase is a challenge. Scaling up is something very technical people like yourself understands well. It is usually all about getting the architecture right and removing global locks and other bottlenecks. However, scaling down is not a technical problem but rather a philosophical one. It is about the overall approach, coming up with ways to make complicated concepts simple to understand, great documentation with simple examples and presenting an approachable ecosystem which extends well beyond the language itself. Very early versions of PHP v1 actually had distinct list, map and set implementations but I replaced those early on with a unified hybrid ordered map implementation and just called it the "Array" type. The thinking was that in almost all situations in a Web app, an ordered map can solve the problem. It looks and acts enough like an array that it can be used in situations that call for an array and it eliminates the problem of presenting the user with 3 or 4 types and related keywords and syntax that forces them to try to figure out which one to use when. This decision was made in 1994 and apart from a few pedantic naming complaints over the years, I think this particular decision has stood the test of time. I don't think this generator question is any different. We need to explain generators in the simplest way possible. The simplest way to explain generators is to not even worry about them being generators at all. Simply say that functions can now return arrays one element at a time using the new yield keyword. That's all. -Rasmus