From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jon Wilson Newsgroups: gmane.lisp.guile.user Subject: How could this be implemented? Date: Sun, 14 Jan 2007 16:50:07 -0600 Message-ID: <45AAB39F.6000408@fastmail.fm> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7BIT X-Trace: sea.gmane.org 1168893473 3859 80.91.229.12 (15 Jan 2007 20:37:53 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 15 Jan 2007 20:37:53 +0000 (UTC) Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jan 15 21:37:52 2007 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 1H6XSH-0008EB-Un for guile-user@m.gmane.org; Mon, 15 Jan 2007 20:25:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H6EBA-0004sn-Ol for guile-user@m.gmane.org; Sun, 14 Jan 2007 17:50:20 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H6EAx-0004si-6j for guile-user@gnu.org; Sun, 14 Jan 2007 17:50:07 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H6EAs-0004sW-EI for guile-user@gnu.org; Sun, 14 Jan 2007 17:50:06 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H6EAs-0004sT-As for guile-user@gnu.org; Sun, 14 Jan 2007 17:50:02 -0500 Original-Received: from [131.225.111.11] (helo=mailgw1.fnal.gov) by monty-python.gnu.org with esmtp (Exim 4.52) id 1H6EAr-0006mv-FS for guile-user@gnu.org; Sun, 14 Jan 2007 17:50:01 -0500 Original-Received: from mailav2.fnal.gov (mailav2.fnal.gov [131.225.111.20]) by mailgw1.fnal.gov (iPlanet Messaging Server 5.2 HotFix 2.06 (built Mar 28 2005)) with SMTP id <0JBV00KD2REIKT@mailgw1.fnal.gov> for guile-user@gnu.org; Sun, 14 Jan 2007 16:49:59 -0600 (CST) Original-Received: from mailgw2.fnal.gov ([131.225.111.12]) by mailav2.fnal.gov (SAVSMTP 3.1.7.47) with SMTP id M2007011416495800181 for ; Sun, 14 Jan 2007 16:49:58 -0600 Original-Received: from conversion-daemon.mailgw2.fnal.gov by mailgw2.fnal.gov (iPlanet Messaging Server 5.2 HotFix 2.06 (built Mar 28 2005)) id <0JBV00I01QT6RG@mailgw2.fnal.gov> (original mail from j85wilson@fastmail.fm) for guile-user@gnu.org; Sun, 14 Jan 2007 16:49:59 -0600 (CST) Original-Received: from [192.168.0.2] (cpe-24-162-120-52.hot.res.rr.com [24.162.120.52]) by mailgw2.fnal.gov (iPlanet Messaging Server 5.2 HotFix 2.06 (built Mar 28 2005)) with ESMTPA id <0JBV00DEBRFAMM@mailgw2.fnal.gov> for guile-user@gnu.org; Sun, 14 Jan 2007 16:49:59 -0600 (CST) Original-To: Guile Users User-Agent: Thunderbird 1.5.0.9 (X11/20070103) 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:5776 Archived-At: Hi, I've been toying with an odd little idea for a bit. It would add a whole slew of symbols to guile's toplevel, but might well make it much more useful as a shell or as a system administration scripting language. Suppose that we could run executable files found in the $PATH as if we were just calling a function? So, to change our current working directory, we would just do: (cd /) Or, for instance, we might do: (ls -a /home/fooguy/.gnome*) The return value of such an expression would be a read-write port connected to stdin and stdout for the program running. When eval found a symbol in the first spot of a list that it didn't know, it would convert the symbol to a string and search the $PATH just like, say, bash does. If it found an executable there with a name matching the string, then it would execute that file. The arguments would be handled thusly: If the argument is a symbol, and it is bound to some value that we can see, then convert that value to a string and use the resulting string as the executable's argument. If the argument is a symbol, but it is not bound to anything that we can see, then convert that symbol directly to a string and use for the executable. If the argument is a list, try to execute that list as a function call, convert the result to a string, and use that. If trying to execute the list results in executing another program from the $PATH, then pack up all the output (stdout) from the program into a string (or maybe tokenize it like the shell would... not sure here) and use that string. If the argument is any other primitive data type, convert it to a string and use that. I suppose it would make things easiest if we used the existing command interpreter (a la the system function, rather than the system* function). Then we could just concatenate all the strings (with spaces in between) and pass them to (system all-our-strings) without worrying about how they should actually be broken up. So, anyway, my primary question is: how could something like this be implemented? It would involve a change, I suppose, to the evaluator. Could it be made as an extension to eval which is added when you load a module? Perhaps more pertinent: Could it be written in guile scheme, or would it require messing with guile itself in C? If it can't be written in guile scheme, should it be able to be written in guile scheme and how difficult would it be to add something like that (eval-extension) to guile? Is this sort of thing what the evaluator-traps thingy is for? Regards, Jon _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user