From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpout02-ext2.partage.renater.fr (smtpout02-ext2.partage.renater.fr [194.254.241.33]) by sourceware.org (Postfix) with ESMTP id 835FC3972494 for ; Fri, 4 Dec 2020 08:05:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 835FC3972494 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=oca.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=damien.mattei@oca.eu Received: from zmtaauth02.partage.renater.fr (zmtaauth02.partage.renater.fr [194.254.241.25]) by smtpout20.partage.renater.fr (Postfix) with ESMTP id C9CD9BFDD1 for ; Fri, 4 Dec 2020 09:05:17 +0100 (CET) Received: from zmtaauth02.partage.renater.fr (localhost [127.0.0.1]) by zmtaauth02.partage.renater.fr (Postfix) with ESMTPS id 5D215A00E0 for ; Fri, 4 Dec 2020 09:05:09 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zmtaauth02.partage.renater.fr (Postfix) with ESMTP id 59694A00DE for ; Fri, 4 Dec 2020 09:05:09 +0100 (CET) X-Virus-Scanned: amavisd-new at zmtaauth02.partage.renater.fr Received: from zmtaauth02.partage.renater.fr ([127.0.0.1]) by localhost (zmtaauth02.partage.renater.fr [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id fSgFba_ivacj for ; Fri, 4 Dec 2020 09:05:09 +0100 (CET) Received: from 90.116.117.253 (unknown [194.254.241.250]) by zmtaauth02.partage.renater.fr (Postfix) with ESMTPA id 23693A00E0 for ; Fri, 4 Dec 2020 09:05:09 +0100 (CET) Reply-To: Damien.Mattei@unice.fr Subject: Re: Using eval with environments and R7RS modules To: kawa@sourceware.org References: <3c4fc600-110f-e1fe-4421-aeb91c8fab22@oca.eu> <60e9b887-73ef-76f8-87e1-a8158802beef@bothner.com> <350b87e4-498f-8108-c2f5-f5397356b10f@oca.eu> From: Damien MATTEI Message-ID: <4fac0c5b-ff16-66e8-d909-94531be10c18@oca.eu> Date: Fri, 4 Dec 2020 09:05:08 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr X-Renater-Ptge-SpamState: clean X-Renater-Ptge-SpamScore: 0 X-Renater-Ptge-SpamCause: gggruggvucftvghtrhhoucdtuddrgedujedrudeijedguddujecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucftgffptefvgfftnecuuegrihhlohhuthemuceftddtnecunecujfgurheprhfuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeffrghmihgvnhcuofetvffvgffkuceouggrmhhivghnrdhmrghtthgvihesohgtrgdrvghuqeenucggtffrrghtthgvrhhnpefgjedvleffffekheejjeehvdegveehtdeiteffkefffedtledvvddugfffjedvffenucfkphepudelgedrvdehgedrvdeguddrvdehtdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleegrddvheegrddvgedurddvhedtpdhhvghlohepledtrdduudeirdduudejrddvheefpdhmrghilhhfrhhomhepffgrmhhivghnucfotefvvffgkfcuoegurghmihgvnhdrmhgrthhtvghisehotggrrdgvuheqpdhrtghpthhtohepkhgrfigrsehsohhurhgtvgifrghrvgdrohhrgh Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=1.7 required=5.0 tests=BAYES_20, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_HELO_IP_MISMATCH, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: kawa@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Kawa mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Dec 2020 08:05:22 -0000 Le 02/12/2020 =C3=A0 15:58, Jamison Hope a =C3=A9crit=C2=A0: > On Mon, Nov 30, 2020 at 1:09 PM Damien MATTEI wr= ote: > >> strange that the SICP cover book put the couple EVAL / APPLY as >> important notion, APPLY seems more usefull, > > FWIW, I would point out that SICP is *not* a book on how to program in > Scheme. It uses Scheme, yes, but much like the pseudo code in CLRS, it=E2= =80=99s > just as an easy-to-understand syntax for presenting concepts about > programming. We did have to write and run some programs in 6.001 on act= ual > computers for homework, but most of the work was done on paper or a > chalkboard. (There were no computers in the room for the final exam.) > > The pair of EVAL/APPLY presented the two stages of *Interpreting* a > Computer Program using the environment model: after parsing the Structu= re > (which for Lisp just means turning text with parentheses into a list of > atoms and lists =E2=80=94 I don=E2=80=99t recall SICP mentioning vector= literals, but it=E2=80=99s > been a while), the two steps to interpret the program =E2=80=94 to deci= de what the > program=E2=80=99s result is =E2=80=94 are to evaluate the car of the li= st to see what > function it represents, then evaluate each function argument, and then = to > apply the function to its arguments (each of those EVAL steps might ent= ail > recursively EVAL/APPLYing an inner function application). There=E2=80=99= s a little > more to it to handle special forms like IF which don=E2=80=99t evaluate= every > argument first, but that=E2=80=99s the essence of the model. i was just trying some sort of coding, for evaluating a postfix expressio= n : i started with recusively EVALuating all but unfortnately it worked only=20 at TOPLEVEL and finally 3 page of wrong code with EVAL where replaced by a single=20 special form: ;; (define x 7) ;; (postfix ((2 (3 2 +) *) x +)) -> 17 ;; (let ((x 7)) (postfix ((2 (3 2 +) *) x +))) -> 17 (define-syntax postfix (syntax-rules () =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 ((= _ (a ... op)) ((postfix op) (postfix a) ...)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 ((= _ a) a) ;; MUST be here not before to avoid ambigious call =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 ;;= misenterpreting a =3D (a ... op) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 )) > This was really a mental exercise, not a description of how a real phys= ical > computer does or should work. The chapter on register machines and > compilation addresses the fact that in reality we don=E2=80=99t need to= use EVAL to > look up each variable at runtime, because we can precompute where that > variable resides in the stack based on where it was defined (see the > section called =E2=80=9CLexical Addressing=E2=80=9D). > > >> >> Damien >> >> -JH