X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=dSOQcCSB5ptLfEp57kH+2G9IOiGabvYHXiOrDlCkCbQ=; b=GdRODIGW6SlJXZiTyNdubHVK1M5GmE+di4fntQ110PbFvaLHc5acgqrVN9lYbaV/T/ I/GuPJ3DqrfaQFlJtkbC/PoyQK3GYwL5utKX3vRSPpGVf0eznNnmNE6SgUC2vSDXZxz3 peCIYJWva9US/T8s5X7g/amFESQHlu+4arCXu8X4iEPXJgOwimxhXUZj/ehDybKfSiew kAjkcPHjsmdhHs8n/hDR5htLPxTQqWZlNbC1LlqGLc2KH/UuE/P5PS7zAteNFLNZLMau 74N3TTHQDe3+mmYZtAEyJ1DQzZX+TJ5ulOC6vi+aHSeE07wi2rR/ntK1gCwiUHa70Nm3 NEug== X-Received: by 10.25.88.67 with SMTP id m64mr13748552lfb.23.1445970399689; Tue, 27 Oct 2015 11:26:39 -0700 (PDT) Date: Tue, 27 Oct 2015 21:26:36 +0300 From: "Vladimir Zhbanov (vzhbanov AT gmail DOT com) [via geda-user AT delorie DOT com]" To: geda-user AT delorie DOT com Subject: Re: [geda-user] A lesson from gnet-makefile Message-ID: <20151027182636.GA18969@localhost.localdomain> Mail-Followup-To: geda-user AT delorie DOT com References: <88EA58F5-2B23-498A-9E5B-84054976DBED AT noqsi DOT com> <4D3CD563-D8EE-4B2A-975A-AC2B573960FF AT noqsi DOT com> <20151016213030 DOT GC2813 AT localhost DOT localdomain> <56228E23 DOT 8060309 AT ecosensory DOT com> <20151020171807 DOT GA16826 AT localhost DOT localdomain> <20151020215438 DOT 3DDE58104E54 AT turkos DOT aspodata DOT se> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20151020215438.3DDE58104E54@turkos.aspodata.se> User-Agent: Mutt/1.5.23 (2014-03-12) Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk Karl, sorry for delay, On Tue, Oct 20, 2015 at 11:54:38PM +0200, karl AT aspodata DOT se wrote: ... > As for nr 4, well yes interpreted lang. takes you faster to runtime, > but I don't see what the author see is so special about the while do, There is usually no need for 'while' and 'do' since most things are done just using tail calls (improved recursion), and those things are just wrappers for them (and there are procedures to see how they wrap them). > or about closures, I read this: > > https://www.gnu.org/software/guile/manual/html_node/Closure.html#Closure > > but I fail to see any definition of what a closure really is, is it a > (let ...) thing containing a lambda expression ? > (And lambda, isn't that just a function without name ?) Yes, lambda is just a function without name, and it is sometimes very useful because it is not always convenient to name a block of code in order just to use it several times. It also allows using of currying [1]. All this is about 'lambda calculus' [2] that is a scientific phenomenon in programming being a foundation of several modern programming languages. In two words, it is sometimes convenient to split functionality if you know that F (Y, X) = F ( Y(X) ). Say, in the following example I separate the map function and another function 'a' which I cannot name yet: (define f (lambda (a ls) (map (lambda (x) (a x)) ; here x is any member of the list ls ls))) Then I can do (f + ls) or (f - ls) to add or subtract members of a list. If the unnamed function gets complicated enough, or when I want to use it in other places, I can split it off at any time and write (define (myfunc .....)) (define f (lambda (a ls) (map myfunc ls))) > > I read > > https://www.gnu.org/software/guile/manual/html_node/Serial-Number.html#Serial-Number > > but isn't that the same as > > static some_struct x; > void some_init() { x = ...; }; > some_run() { do something; } > > It feels like I'm blind and don't see what's so special about this. > And reading thoose two links I get a feeling that the author says the > same thing about something I'm used to, but he/she uses for me > unfamiliar words, which make it a really hard to understand it. The major thing about closures is that they save not only code, but also their toplevel environment in them (the underlying technique, AFAIK, is catching current program stack), thereby allowing encapsulation without using any OOP. You can create opaque structures with getters and setters allowing users use only them to access data, where you can remember toplevel variables you want. Then there would be far less possibilities to break anything (compared with plain C constants and functions, IIUC). Besides, as it is shown in the manual, you can easily copy the functionality of closure you made by creating the closure inside another procedure (this is used as an example of making several independent serial numbers generators). Yes, you can always duplicate things in C (since at least Guile core is written in C), however you'll have to do more work then. This is the same thing as if I would compare C and asm. (Almost) all things you do in C you could do in asm (I'm wording 'almost' and 'could' because some things would require too much work, especially ones ensuring portability). However, C is much better than asm for most cases, you know :) Returning to closures, please try searching e.g. 'closure advantages' in google for more info on them. You'll also see that closures are used in many modern hi-level languages. > > So, is there a scheme book for c programmers ? Not that I know of. AIUI, Scheme must not be C dependent. OTOH, as long as Guile is GNU Scheme aimed at extending programs in C, and if you want to be aware of functions which could be used for that, you can look through the fifth chapter of the guile info manual (it is available on-line, search for 'guile Programming and C' and you'll find [3] :)). > And, you know, there are dictionaries available when travelling abroad, > which one should I use when going to scheme-land ? > I don't think I understand you here. If you mean any unknown terms, you may try to look up them in wikipedia. Cheers, Vladimir [1] https://en.wikipedia.org/wiki/Currying [2] https://en.wikipedia.org/wiki/Lambda_calculus [3] https://www.gnu.org/software/guile/manual/html_node/Programming-in-C.html