From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: vm branch now uses vm repl by default Date: Tue, 09 Sep 2008 08:48:50 +0200 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1220942989 17343 80.91.229.12 (9 Sep 2008 06:49:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Sep 2008 06:49:49 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Sep 09 08:50:43 2008 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Kcx3g-0004hz-3I for guile-devel@m.gmane.org; Tue, 09 Sep 2008 08:50:40 +0200 Original-Received: from localhost ([127.0.0.1]:48946 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kcx2g-0001IQ-26 for guile-devel@m.gmane.org; Tue, 09 Sep 2008 02:49:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kcx2Y-0001IL-2D for guile-devel@gnu.org; Tue, 09 Sep 2008 02:49:30 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kcx2X-0001I4-Dx for guile-devel@gnu.org; Tue, 09 Sep 2008 02:49:29 -0400 Original-Received: from [199.232.76.173] (port=35317 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kcx2X-0001I1-8z for guile-devel@gnu.org; Tue, 09 Sep 2008 02:49:29 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:42300) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kcx2W-0003fO-RA for guile-devel@gnu.org; Tue, 09 Sep 2008 02:49:29 -0400 Original-Received: from a-sasl-fastnet.sasl.smtp.pobox.com ([207.106.133.19] helo=sasl.smtp.pobox.com) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kcx2U-0003K1-RK for guile-devel@gnu.org; Tue, 09 Sep 2008 02:49:26 -0400 Original-Received: from localhost.localdomain (localhost [127.0.0.1]) by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTP id 598C460DCA for ; Tue, 9 Sep 2008 02:49:06 -0400 (EDT) Original-Received: from unquote (251.Red-83-32-65.dynamicIP.rima-tde.net [83.32.65.251]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTPSA id 7E64A60DC9 for ; Tue, 9 Sep 2008 02:49:05 -0400 (EDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-Pobox-Relay-ID: 659703D0-7E3B-11DD-800D-D0CFFE4BC1C1-02397024!a-sasl-fastnet.pobox.com X-detected-kernel: by mx20.gnu.org: Solaris 10 (beta) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:7629 Archived-At: Hi, I've enabled the VM repl by default on the vm branch. Here's a brief annotated tour: $ ./pre-inst-guile Guile Scheme interpreter 0.5 on Guile 1.9.0 Copyright (C) 2001-2008 Free Software Foundation, Inc. Enter `,help' for help. A very pleasant introduction, no? And totally configurable with a nice programming interface. scheme@(guile-user)> 'foo $1 = foo A normal repl. The `scheme' indicates the current language, and (guile-user) is the current module. The $1 = foo is from the history module. If you don't have this in your ~/.guile, you really really want it: (use-modules (ice-9 readline) (ice-9 history)) (activate-readline) Anyway, moving on: scheme@(guile-user)> (lambda () (pk a #:bar)) $2 = # Entering in expressions actually compiles and executes them. In this case we compiled and loaded a thunk. Compiled procedures are "programs", and print as such. scheme@(guile-user)> (define a '(a . pair)) scheme@(guile-user)> ($2) ;;; ((a . pair) #:bar) $3 = #:bar Procedures resolve toplevel bindings lazily, as in the interpreter, so you get letrec semantics in the repl. scheme@(guile-user)> ,x $2 There is a wealth of meta-commands at the repl, commands that start with `,'. This command, `,x', is an abbreviation for `,disassemble'. Its output is this: Disassembly of #: nargs = 0 nrest = 0 nlocs = 0 nexts = 0 The program has no arguments, no rest arguments, no local variables, and no external (lexically-bound) variables. Bytecode: 0 (late-variable-ref 0) 2 (late-variable-ref 1) 4 (object-ref 2) ;; #:bar 6 (tail-call 2) Objects: 0 #> 1 # 2 #:bar Late-variable-ref looks at a cell in the object vector. If it is a symbol, it is resolved relative to the module that was current when the program was made. The object cell is then replaced with the resulting resolved variable. Here we see that objects 0 and 1 were already resolved. Object 2 is just the constant, #:bar. All of the ref instructions push their values on the stack. Call instructions pop off arguments, if any, then call the program on the top of the stack. In this case it is a tail call. Sources: 8 #(1 11 #f) Some instructions are annotated with source information. In this case, when the instruction pointer is at 8 (right after the tail-call -- one byte for tail-call and one for the number of arguments, 2), the original source was at line 1 and column 11 in an unnamed port (stdin in this case). scheme@(guile-user)> ,option interp #t scheme@(guile-user)> ,option trace #f interp #t Here we tell the repl that, given the option, we prefer to interpret rather than compile. Of course, if the current language doesn't support compilation, we always interpret. scheme@(guile-user)> (lambda () (pk a #:bar)) $4 = # An interpreted procedure, like in olden times. Happy hacking! Andy -- http://wingolog.org/