From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mike Gran Newsgroups: gmane.lisp.guile.user Subject: Re: Clean Guile code from C program Date: Fri, 7 Mar 2008 10:30:12 -0800 (PST) Message-ID: <283059.72019.qm@web37910.mail.mud.yahoo.com> References: <20080307180233.4CC038B31C@xprdmxin.myway.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1204914763 9798 80.91.229.12 (7 Mar 2008 18:32:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Mar 2008 18:32:43 +0000 (UTC) To: maitai02@excite.com, guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Mar 07 19:33:10 2008 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JXhND-00009r-U3 for guile-user@m.gmane.org; Fri, 07 Mar 2008 19:32:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JXhMc-0001at-Es for guile-user@m.gmane.org; Fri, 07 Mar 2008 13:32:14 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JXhLV-00018u-8g for guile-user@gnu.org; Fri, 07 Mar 2008 13:31:05 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JXhLS-00016N-Av for guile-user@gnu.org; Fri, 07 Mar 2008 13:31:04 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JXhLS-00016G-4a for guile-user@gnu.org; Fri, 07 Mar 2008 13:31:02 -0500 Original-Received: from web37910.mail.mud.yahoo.com ([209.191.91.172]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1JXhLR-0001gX-UD for guile-user@gnu.org; Fri, 07 Mar 2008 13:31:02 -0500 Original-Received: (qmail 83602 invoked by uid 60001); 7 Mar 2008 18:30:12 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=zIVt+asFsKXIUl7qZH0+1SEP/qEOTqkJYN/YHqHsqifL7xfCfYnipTX6DoHKeQWp9D0K32xnKdkW8Qpbp6LGisiVS5QsGner8mu9fcNjdL9YQxK9mbZa9f5xKk57vGJDi2V7eeYcLxCfHrJsPFUw8I6hX2Bg1DrGpnN3HzodzWw=; X-YMail-OSG: sITDbagVM1mZJtEHX5o5fmChOX9C7m4Udgd6zLG.cOJwziXRK0dlYNqdpsd9HTL3HQ-- Original-Received: from [64.52.12.172] by web37910.mail.mud.yahoo.com via HTTP; Fri, 07 Mar 2008 10:30:12 PST In-Reply-To: <20080307180233.4CC038B31C@xprdmxin.myway.com> X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.7-5.2 (or MacOS X 10.2-10.4) (2) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:6447 Archived-At: --- Jose Martin wrote: > I looked at the program's code and it looks a bit > difficult to change it, and I must say I'm a > beginner in C. Could anyone give me the steps of the > changes I'd need to remove Guile-dependent code from > C code? Wow. The Guile stuff is pretty well entangled. If you don't know enough C (and I think I saw some C++ in there as well) you might be in over your head. But, FWIW, here's how you'd do it. 1. For every variable and function declared as type SCM, figure out what type of information actually goes in that variable. Choose an appropriate C type instead. 1a. This code creates a special Guile type textmgr which is, underneath, a C++ class textmgr. Wherever the textmgr stuff is used, call the C++ class's procecures instead. 2. For every function that begins with scm_, check the docs for its purpose and recode them in C. You can usually ignore the scm_????_p functions because they check the type of the variable, which won't be necessary once you convert everything into appropriate C types. 3. The scm_shell creates a loop that displays a prompt, takes user-typed commands, executes them, and displays the output. Invent some sort of input scheme or input language and write a parser for it. Have it execute the commands that the user typed in. (The "readline" calls invoke a library called readline which does command history stuff. Your parser could use the C API of readline instead.) 4. Make sure that your C datatypes are freed appropriately. 5. ??? 6. Profit! Good luck! -- Mike Gran