From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: Eval, tail calls, (current-module), and backward compatibility Date: Sat, 21 Jan 2012 13:28:59 -0500 Message-ID: <87y5t0ucyc.fsf@netris.org> References: <87lip70zz7.fsf@netris.org> <87ty3pjbcl.fsf@fencepost.gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1327170601 4135 80.91.229.12 (21 Jan 2012 18:30:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 21 Jan 2012 18:30:01 +0000 (UTC) Cc: guile-devel@gnu.org To: David Kastrup Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Jan 21 19:29:56 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RofhM-0008UA-Bn for guile-devel@m.gmane.org; Sat, 21 Jan 2012 19:29:56 +0100 Original-Received: from localhost ([::1]:58003 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RofhL-0006WS-Kl for guile-devel@m.gmane.org; Sat, 21 Jan 2012 13:29:55 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:50847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RofhI-0006WC-7y for guile-devel@gnu.org; Sat, 21 Jan 2012 13:29:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RofhH-0004GW-3T for guile-devel@gnu.org; Sat, 21 Jan 2012 13:29:52 -0500 Original-Received: from world.peace.net ([96.39.62.75]:39473) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RofhH-0004GS-0z; Sat, 21 Jan 2012 13:29:51 -0500 Original-Received: from c-98-216-245-176.hsd1.ma.comcast.net ([98.216.245.176] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1RofhB-0002yo-0F; Sat, 21 Jan 2012 13:29:45 -0500 In-Reply-To: <87ty3pjbcl.fsf@fencepost.gnu.org> (David Kastrup's message of "Sat, 21 Jan 2012 16:59:06 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 96.39.62.75 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:13617 Archived-At: David Kastrup writes: > Mark H Weaver writes: > >> Ideally, I think that `eval' should set (current-module) during >> expansion, but _not_ during evaluation. Then it can be properly tail >> recursive. However, some code out there might depend on the existing >> behavior, so I guess we can't change this, at least not in 2.0. >> Bummer. > > It just occured to me that the _only_ way of getting and setting > variables under a computed name (apart from using macros) is using > (module-set! (current-module) (compute a symbol)) > since symbol-set! apparently has been deprecated. If you want to get or set a top-level variable with a computed name, then you need to know which module to use. Otherwise, how could Guile possibly know which module you intended? Remember, (current-module) is a compile-time concept, not a run-time concept. It is probably not the right choice except in something like a REPL, and only if you specifically want the same module that's being used to compile new top-level forms (using `primitive-eval'). It's unfortunate, but just as support for multiple string encodings forces us now to think clearly about which encoding to use for a given bytevector in our code (and there's really no way around this), the same is also true of modules. For non-computed variable references, there is a robust automatic answer: use the module that was baked into the source identifier before macro expansion. However, this cannot be done for computed variable names. Thanks, Mark