From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Keith Wright Newsgroups: gmane.lisp.guile.user Subject: Re: C++ declaration style programming? Date: Wed, 21 Jan 2004 16:46:56 -0500 Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: <200401212146.i0LLkudj002153@fcs10.free-comp-shop.com> References: <16397.43262.881852.180514@localhost.localdomain> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1074722236 27950 80.91.224.253 (21 Jan 2004 21:57:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 21 Jan 2004 21:57:16 +0000 (UTC) Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Jan 21 22:57:07 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AjQLT-0005ro-00 for ; Wed, 21 Jan 2004 22:57:07 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AjQCA-00029l-3n for guile-user@m.gmane.org; Wed, 21 Jan 2004 16:47:30 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AjQAp-00022v-LH for guile-user@gnu.org; Wed, 21 Jan 2004 16:46:07 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AjQAH-0001uP-VO for guile-user@gnu.org; Wed, 21 Jan 2004 16:46:05 -0500 Original-Received: from [216.254.0.201] (helo=mail1.speakeasy.net) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.24) id 1AjQ8a-0001Qg-HA for guile-user@gnu.org; Wed, 21 Jan 2004 16:43:48 -0500 Original-Received: (qmail 30850 invoked from network); 21 Jan 2004 21:43:34 -0000 Original-Received: from dsl092-074-188.bos1.dsl.speakeasy.net (HELO free-comp-shop.com) ([66.92.74.188]) (envelope-sender ) by mail1.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 21 Jan 2004 21:43:34 -0000 Original-Received: from fcs10.free-comp-shop.com (localhost.localdomain [127.0.0.1]) by free-comp-shop.com (8.12.8/8.12.8) with ESMTP id i0LLkuVg002155 for ; Wed, 21 Jan 2004 16:46:57 -0500 Original-Received: (from kwright@localhost) by fcs10.free-comp-shop.com (8.12.8/8.12.8/Submit) id i0LLkudj002153; Wed, 21 Jan 2004 16:46:56 -0500 Original-To: guile-user@gnu.org In-reply-to: <16397.43262.881852.180514@localhost.localdomain> (message from Han-Wen Nienhuys on Tue, 20 Jan 2004 23:17:34 +0100) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.user:2683 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:2683 > From: Han-Wen Nienhuys > > However, it doesn't work so well when I mix commands with > declarations, eg. > > > int var1 = something (); > var1 += 2; > int var2 = something (var1); > var2 += var1; > int var3 = something (var1, var2); > etc. > I realize this is just an example of syntax, several people have pointed out that computing a value of 'var1' only to change it has some lameness to it, but if you need to do that... (let* ((var1 (let ((var1-ini (something))) (+ 2 var1-ini))) (var2 (let ((var2-ini (something var1))) (+ var2-ini var1))) (var3 (something var1 var2)) ) etc) You can use the first guess value as many times as you need to compute the final value, but then it goes out of scope and doesn't clutter all that follows. If the imperative commands are part of computing the following variable then... (let* ((var1 (something)) (var2 (begin (set! var1 (+ 2 var1)) (something var1) )) (var3 (begin (set! var2 (+ var2 var1)) (something var1 var2) ))) etc) If the imperative stuff is not related to either the preceding or following declaration, then maybe it should be moved out of the middle. Just a thought, hope this helps, do what you will is the whole of the law. -- -- Keith Wright Programmer in Chief, Free Computer Shop --- Food, Shelter, Source code. --- _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user