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: extending FEM enginering package with Guile Date: Wed, 7 Jan 2004 23:58:25 -0500 Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: <200401080458.i084wPKw002504@fcs10.free-comp-shop.com> References: <200401051920.i05JKHsC023665@minerva.ceride.gov.ar> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1073538200 20190 80.91.224.253 (8 Jan 2004 05:03:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 8 Jan 2004 05:03:20 +0000 (UTC) Cc: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Jan 08 06:03:15 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 1AeSKB-0004uy-00 for ; Thu, 08 Jan 2004 06:03:15 +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 1AeTCt-0008Iu-DG for guile-user@m.gmane.org; Thu, 08 Jan 2004 00:59:47 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AeTAd-00073h-2d for guile-user@gnu.org; Thu, 08 Jan 2004 00:57:27 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AeTA0-0006a1-Fl for guile-user@gnu.org; Thu, 08 Jan 2004 00:57:20 -0500 Original-Received: from [216.254.0.202] (helo=mail2.speakeasy.net) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.24) id 1AeT9z-0006Qg-Bg for guile-user@gnu.org; Thu, 08 Jan 2004 00:56:47 -0500 Original-Received: (qmail 12905 invoked from network); 8 Jan 2004 04:55:07 -0000 Original-Received: from dsl092-074-188.bos1.dsl.speakeasy.net (HELO free-comp-shop.com) ([66.92.74.188]) (envelope-sender ) by mail2.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 8 Jan 2004 04:55:07 -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 i084wR87002506; Wed, 7 Jan 2004 23:58:27 -0500 Original-Received: (from kwright@localhost) by fcs10.free-comp-shop.com (8.12.8/8.12.8/Submit) id i084wPKw002504; Wed, 7 Jan 2004 23:58:25 -0500 Original-To: mstorti@intec.unl.edu.ar In-reply-to: <200401051920.i05JKHsC023665@minerva.ceride.gov.ar> (message from Mario Storti on Mon, 05 Jan 2004 16:20:17 -0300) 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:2557 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:2557 > From: Mario Storti > > .... But there is one point which I find too > hard, and is the looping constructs. I think that explaining to the > users concepts like tail-call recursion, Don't loop, recursion is easier. Don't believe it? Look in your math books. You may find recursion, often called induction, but mathemeticians never loop. They don't have to, so they do it the easy way. > or call/cc's is an overkill. Definitely stay away from call/cc. It _is_ hard, and the Guile implementation may be buggy. (Was in version 4, and nobody knew how to fix it. I haven't tested version 6 for this.) > I'm not speculating here, I have talked with many of them > (those with better programming skills). You asked if they could understand recursion, and they said "No"? > Perhaps such things may be used by the developers, but definitely > not by the average user. Everybody uses recursion in Scheme. > There is the `while' special form, but even with this some simple > looping constructs, like the following in C/C++ > > while (cond0) { > // body1 0; > // ... > if (cond1) break; > // body 1 > // ... > if (cond2) continue; > // body 2 > // ... > } > > are hard to write, due to the lack of `break' and `continue' in > Scheme. Don't use while in the first place. Use "named LET". Then BREAK is just computing the final answer, and "continue" is calling the named LET procedure. > I think that one can do that with catch/throw but it also seems > an overkill. And ugly and stupid. Besides, Scheme doesn't have catch/throw (it's added in Guile and maybe some other implementations). > I found some flame wars between some other Lisp dialects and Scheme > and I anticipate that I'm not interested in starting such a > discussion. So: > > Question 1: I ask simply if there is some simple way of writing code > like this previous one in Scheme. (let loop ([var1 init1] [var2 init2]) (if (cond1) (compute answer)) ; ... (if (cond2) (loop (new-var1) (new-var2))) ; ... (loop (new-var1) (new-var2)) ; end-of-loop = continue ) > Question 2: I have learned that in Scheme it is considered bad > practice to `set!' variables, or in general to use side-effects. In > our applications we manipulate huge structures (mainly vectors, sparse > matrices, graphs, with sizes in the order of several hundredths MBs, > and running for weeks), and it seems much more efficient to code this way > (using side-effects). Am I right? It depends on what the side effects are. If, in the middle of inverting a matrix, you start dorking around with the values of unrelated global variables you are probably messing up. Just compute your inverse (or whatever) and return it as the answer. Do not find or make some global variable to SET! to the answer. On the other hand, to compute your final answer you may want to allocate a big vector (matrix, graph) full of zeroes (say) as a local variable and compute the result by repeatedly updating elements. When your procedure returns the answer the local variables disappear, only the result is returned, and nobody need know about the VECTOR-SET! you did inside your procedure. -- Keith _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user