Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61854 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14811 invoked from network); 28 Jul 2012 07:09:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jul 2012 07:09:52 -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.49 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.216.49 mail-qa0-f49.google.com Received: from [209.85.216.49] ([209.85.216.49:59098] helo=mail-qa0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 20/54-23870-F3093105 for ; Sat, 28 Jul 2012 03:09:52 -0400 Received: by qabj40 with SMTP id j40so185398qab.8 for ; Sat, 28 Jul 2012 00:09:49 -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=btsFjVSgn8zQUpemniKVDvq7d8/E1WoUMJKOBZ2xlbY=; b=dJgrr9Gx9SAS0cFfIxH9Gy/rN2PdyI0QQg9GHDskule/28YyplMkrA3FfhIwvgTlMy 9HJgVhWeHlB/plGLuBJW+qnWzNBgiKJL7ucw0Ox9EJTEbm0znnV6fMizr+Ul1sZmIUMd TVc814/8UBLYnCqpaJYzFe9h/MkfCU2uv2Viwmw7Wm8o1mfxyz2Wa8vfDu0yWlGfiSlc JsJDE5eF9cwgnN3Y00xVhFwI0VOWDPFB6LPMSsfMqUwuXRhKPusJmWdsnJ00wt23PNF1 Pj2JT6+2T1SQg/Ktx8H9N5ODI6zjVhHlslZA68wn6WrVvV8fQ8XZQ+j8vsT16wlXmVe3 EcLw== Received: by 10.229.135.206 with SMTP id o14mr2324952qct.91.1343459389345; Sat, 28 Jul 2012 00:09:49 -0700 (PDT) Received: from [172.16.26.30] ([38.106.64.245]) by mx.google.com with ESMTPS id f14sm3435572qak.20.2012.07.28.00.09.47 (version=SSLv3 cipher=OTHER); Sat, 28 Jul 2012 00:09:48 -0700 (PDT) Message-ID: <5013903A.6030009@lerdorf.com> Date: Sat, 28 Jul 2012 00:09:46 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Lester Caine CC: PHP internals References: <5010138D.5050804@ajf.me> <501015B9.6050704@ajf.me> <501085FE.7070406@lerdorf.com> <501382B3.2090702@lerdorf.com> <50138DD1.1090009@lsces.co.uk> In-Reply-To: <50138DD1.1090009@lsces.co.uk> X-Enigmail-Version: 1.5a1pre Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnsOoNj+EkrFbX3zn38jm9CBdIsEuBLY7Ga0VwBSOcLY4Obf/Kz8oh8V/6dKDpQGorPfq1q Subject: Re: [PHP-DEV] Re: Generators in PHP From: rasmus@lerdorf.com (Rasmus Lerdorf) On 07/27/2012 11:59 PM, Lester Caine wrote: > Rasmus Lerdorf wrote: >> 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. > > It's this 'concept' that I am having trouble seeing in the general > process that is required using PHP to generate web pages. At the end of > the day I have to generate the finished page or sub-page so I need all > the results anyway. Sure, but that doesn't mean it has to all be in memory at the same time. You can read lines from a large file line-by-line, process that line and output the result before you move onto the next line. -Rasmus