From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Maciek Godek" Newsgroups: gmane.lisp.guile.user Subject: Re: Me no understand scoping Date: Sun, 10 Aug 2008 23:49:42 +0200 Message-ID: References: <489074A9.1080508@wilsonjc.us> <49dd78620807310020i8b55067gd22f6ce361a04d7d@mail.gmail.com> <49dd78620807311437g7ab367bdxed293a3b8dbd5753@mail.gmail.com> <49dd78620808021043h66f6d953uff37c35d018afb80@mail.gmail.com> <49dd78620808081354v292fd767q97d8f24bbdb9c6cf@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1218405000 1723 80.91.229.12 (10 Aug 2008 21:50:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 10 Aug 2008 21:50:00 +0000 (UTC) Cc: guile-user@gnu.org To: "Neil Jerram" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Aug 10 23:50:52 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 1KSIoN-0005Wa-3A for guile-user@m.gmane.org; Sun, 10 Aug 2008 23:50:51 +0200 Original-Received: from localhost ([127.0.0.1]:52480 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KSInR-0006aY-8g for guile-user@m.gmane.org; Sun, 10 Aug 2008 17:49:53 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KSInL-0006WJ-3Q for guile-user@gnu.org; Sun, 10 Aug 2008 17:49:47 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KSInJ-0006Sr-7X for guile-user@gnu.org; Sun, 10 Aug 2008 17:49:46 -0400 Original-Received: from [199.232.76.173] (port=59782 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KSInJ-0006Sb-2h for guile-user@gnu.org; Sun, 10 Aug 2008 17:49:45 -0400 Original-Received: from wf-out-1314.google.com ([209.85.200.172]:36583) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KSInI-0004I1-Ka for guile-user@gnu.org; Sun, 10 Aug 2008 17:49:44 -0400 Original-Received: by wf-out-1314.google.com with SMTP id 28so1580777wfc.24 for ; Sun, 10 Aug 2008 14:49:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=VTCm0IkmlheNB6wfOo9MMSYxSRMGdmL3Qc0zDLh+vJY=; b=LfRi7ex1R1KCiP69vTwAQLBwk1Qbd+dWlQ9gbb3o+jaH5WmmmVme+6w4bh7Tz4AdP7 KHDRp3sLLv0sg/MiHDiSbKLHoWd10O+hvdxgk3voxv/iF6MRd/w3QYaUrQ6oBu3EUX3a YqvegzPA8aDLZbXX+DGxqWJX0ieqfhA8inqyo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=sObFFDYjseo7e3/sF0biCPjyBYI9TztZg96e/kdFOcTtSCF5UmCx5B2ciYzI4Dr2s6 9TpG/DpefpdCBgIeTWrI+1RvSHfam6v8I3v3wAKXYAAOX1gU0MWliUo/Y6j8QrlvnTuy xbMzZEoXZcuUTTMwRd0hn66+06IULJb/5gBFc= Original-Received: by 10.142.240.9 with SMTP id n9mr1856946wfh.6.1218404982603; Sun, 10 Aug 2008 14:49:42 -0700 (PDT) Original-Received: by 10.142.164.4 with HTTP; Sun, 10 Aug 2008 14:49:42 -0700 (PDT) In-Reply-To: <49dd78620808081354v292fd767q97d8f24bbdb9c6cf@mail.gmail.com> Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 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:6735 Archived-At: 2008/8/8 Neil Jerram : >> The main reason is that there's no documented way >> of accessing GOOPS objects from C (except from using >> scm_c_eval_string etc.), or at least I couldn't find any >> documentation for that. > > Yes, that's a fair point. And one that keeps coming up. I hope we > can remedy this some time soon. I obviously started to develop my own OO system -- purely to understand everything. By the way I came up with some conclusions regarding objects and classes and that is: - a class can be implemented as a vector of three elements: * vector of methods (closures) * hash table mapping method names to their closures * hash table mapping slot names to vector indices. - an object (instance) could also be implemented as a simple vector -- its first field would be a reference to its class, and the remaining ones would be the slots. Interfacing such a system from the C level is rather straightforward (or at least as straightforward as accessing scm_vectors) and efficient. (Perhaps goops does it more efficiently, I dunno) >> I also get this unpleasant feeling that all these 'getters' >> and 'setters' are entities multiplied beyond necessity >> (even the infamous C++ doesn't explicate them) > > I don't understand you here. And in any case, getters and setters are > optional. You can just use slot-ref and slot-set! if you prefer. I bet you're right. I'm just learning and trying to justify all the features that are provided by goops. Anyway, I can't get rid of a feeling that many of them are redundant and quite random, but I'm still examining it. >> I'm really trying to get close >> to the classical OOP notation: object.method() -- and >> it's probably why I explore the potential of using these >> "poor man's objects" > > Unfortunately that's only "classical" for non-Lisp-like languages! > Still, I'd take your point if you said you wanted to write something > that would be familiar to OO programmers in non-Lisp languages. Fortunately Andy Wingo recommended his essay about this. >> And so I never stopped to believe that (define x 5) is more or >> less equivalent to (hash-set! global-scope 'x 5). > > Well yes.... but I'm afraid I'm still not sure how that leads us to > local-eval ! Sorry if I'm being dumb about this! Its genesis reaches the Kejtil's suggestion for accessing closure's scope. The fact that it is possible in guile lead me to the conclusion that it can be done to implement a simple oo system. (I'm just beginning to realize how inefficient this can be). Thanks a lot M.