From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Dirk Herrmann Newsgroups: gmane.lisp.guile.devel Subject: scm_lookupcar Date: Tue, 25 Jun 2002 22:55:51 +0200 (CEST) Sender: guile-devel-admin@gnu.org Message-ID: NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: main.gmane.org 1025038632 21930 127.0.0.1 (25 Jun 2002 20:57:12 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 25 Jun 2002 20:57:12 +0000 (UTC) Return-path: Original-Received: from fencepost.gnu.org ([199.232.76.164]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 17MxN9-0005hb-00 for ; Tue, 25 Jun 2002 22:57:11 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 17MxN2-00059n-00; Tue, 25 Jun 2002 16:57:04 -0400 Original-Received: from sallust.ida.ing.tu-bs.de ([134.169.132.52]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 17MxLs-00058U-00 for ; Tue, 25 Jun 2002 16:55:53 -0400 Original-Received: from localhost (dirk@localhost) by sallust.ida.ing.tu-bs.de (8.9.3+Sun/8.9.1) with ESMTP id WAA01370 for ; Tue, 25 Jun 2002 22:55:51 +0200 (CEST) Original-To: guile-devel@gnu.org Errors-To: guile-devel-admin@gnu.org X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.devel:706 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:706 Hi folks, thinking of incremental steps to separate memoizing and execution, I think that the current function scm_lookupcar should be split up: * split the functionality of scm_lookupcar into the following subtasks: a) a function to transform a symbol into its memoized form: static SCM symbol2memoized_symbol (SCM symbol, SCM environment); The function searches the environment for the symbol and returns either a variable or an iloc (later, a macro object may also be returned). If the search was not successfull, SCM_UNDEFINED is returned. This function only delivers the memoized object that could replace the symbol, but it does not actually change any code. The idea is, that this function will be used during memoization, but won't have to deal with actual values any more. b) a function, that looks up a symbol and automatically memoizes it: static SCM memoize_symbol_in_car (SCM pair, SCM environment); The symbol to be looked up is found in the car of the pair. The function makes use of the function a) to look up the symbol. If the result from a) is not SCM_UNDEFINED, the car of the pair is overwritten, otherwise it remains unchanged. The function returns the result that was received from a). c) a function that for a variable or an iloc returns a SCM* pointing to the location of the corresponding value: static SCM* memoized_symbol2location (SCM obj, SCM environment); d) a function that for a variable or an iloc returns the value: static SCM memoized_symbol2value (SCM obj, SCM environment); e) a function, similar to scm_lookup_car: static SCM lookup_and_memoize_symbol_in_car (SCM pair, SCM environment); The functionality is similar to scm_lookupcar, but instead of returning a pointer to a value, the value itself is returned. Using these functions, scm_lookupcar can be easily re-implemented. Further, a lot of code that uses scm_lookupcar can be replaced using these functions. A negative impact of this change is, that it will slow down memoization a little bit, since in case of an iloc the environment is scanned twice to actually obtain the result for scm_lookupcar: First, in function symbol2memoized_symbol the environment is scanned to obtain the iloc, second, in function memoized_symbol2location the environment is scanned according to the iloc data. I will add these thoughts to workbook/compilation/evaluation.txt. Best regards, Dirk Herrmann _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel