delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2015/10/18/15:07:02

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=aYfBI6mPtwJvY+N67wOZoHtr0CnG1JWbd74WRMe1XdQ=;
b=TdbHiM5zPVSJlZeR8c3BIl3Bq8hmPqn6OJk6gvFpb5aDukUdnMieGT3Kq9r3CW/P7/
vv0BQo3Hy9945FXpLePs0OXArLAirWxc0s1dBbB72xL0NtqfhDxPdAyh0L5k3RPkAad4
rbClj9twVqEpZNbnfuMNfH/7hF0kJWOBibhIw1WYeyuQ6/e4lnKUj+9lq5Y51g3wXE9v
O/6a8waIHU9Wyc0D5ZbSvTXrspGTirr1zvI5Gm/iVttjMSRkwuJykRAbCwH8MHF0BY/k
Nzq9uTkcMHgc2TL9LOTcfoCfwVfSBQqZjWLhP/8BoFqOKSWGpXVzeVVJzwg/rGAzNqiL
WarA==
X-Received: by 10.112.147.39 with SMTP id th7mr12602030lbb.82.1445195202407;
Sun, 18 Oct 2015 12:06:42 -0700 (PDT)
Date: Sun, 18 Oct 2015 22:06:39 +0300
From: "Vladimir Zhbanov (vzhbanov AT gmail DOT com) [via geda-user AT delorie DOT com]" <geda-user AT delorie DOT com>
To: geda-user AT delorie DOT com
Subject: Re: [geda-user] A lesson from gnet-makefile
Message-ID: <20151018190639.GA2782@localhost.localdomain>
Mail-Followup-To: geda-user AT delorie DOT com
References: <1042003D-82E2-40F0-AB60-8186580C46AD AT noqsi DOT com>
<201510121905 DOT t9CJ5T9W026297 AT envy DOT delorie DOT com>
<CAM2RGhTMnybSnYgnNhVZGA6PTvyJu+=Kzd5LX2HMqxT1F4LoRg AT mail DOT gmail DOT com>
<88EA58F5-2B23-498A-9E5B-84054976DBED AT noqsi DOT com>
<CAM2RGhTPPtqmWVa3=Kf-PeN+WS5Tn4J+D0Ri6R_4OrQOk+LFKQ AT mail DOT gmail DOT com>
<4D3CD563-D8EE-4B2A-975A-AC2B573960FF AT noqsi DOT com>
<CAM2RGhT8WzhwvzFx3Rfv8vN-f=i1=uWuLF+48VygSRtfdzdo-A AT mail DOT gmail DOT com>
<20151016213030 DOT GC2813 AT localhost DOT localdomain>
<20151017215428 DOT 7E79B8104E54 AT turkos DOT aspodata DOT se>
MIME-Version: 1.0
In-Reply-To: <20151017215428.7E79B8104E54@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

Hi Karl,

On Sat, Oct 17, 2015 at 11:54:28PM +0200, karl AT aspodata DOT se wrote:
> Vladimir 
> > On Tue, Oct 13, 2015 at 02:02:53PM -0400, Evan Foss (evanfoss AT gmail DOT com)
> > [via geda-user AT delorie DOT com] wrote:
> ...
> > > I understand that but I would really like to go back and do more of
> > > this in C. The final parsing of the net attributes into xyz output
> > > format should be in scheme. Although I could be wrong.
> > Do it the way you like it. I hope, if we'll have algorithms we need,
> > we'll be able to express them in the language we want.
> > 
> > I can only note that Scheme is a hi-level language wrt C and sometimes
> > (not always) it's better to express things in it rather than in C.
> > 
> > For example, the following code from gsymcheck
> > 
> > ------------------------8<--------------------------
> > SCM_DEFINE (...)
> > {
> > TOPLEVEL* pr_current = edascm_c_current_toplevel ();
> >   GList *iter;
> >   PAGE *p_current;
> >   SCM page_s;
> >   SCM return_status = scm_from_int (0);
> > 
> >  /* C code to check all symbols */
> > 
> >   for ( iter = geda_list_get_glist( pr_current->pages );
> >         iter != NULL;
> >         iter = g_list_next( iter ) ) {
> > 
> >     p_current = (PAGE *)iter->data;
> >     page_s = edascm_from_page (p_current);
> > 
> >     return_status = scm_sum (return_status, check_symbol (page_s));
> >   }
> > 
> >   return return_status;
> > }
> > ------------------------>8--------------------------
> >
> > can be replaced just with
> > 
> > ------------------------8<--------------------------
> > (apply + (map check-symbol (active-pages)))
> > ------------------------>8--------------------------
> > 
> > in guile module (I'm just working on this)
> 
> I consider that an unfair comparison. The the c code have to convert
> the data which is in scheme so it has to do a fair amaount of 
> conversions to please the scheme part of geda, hence it looks messy.

You're right to a certain degree. I've inadvertently shown the last diff
after some rework to make it Scheme compatible instead of the diff with
initial version. Well, the initial version is as follows:
------------------------8<--------------------------
int
s_check_all(TOPLEVEL *pr_current)
{
  GList *iter;
  PAGE *p_current;
  int return_status=0;


  for ( iter = geda_list_get_glist( pr_current->pages );
        iter != NULL;
        iter = g_list_next( iter ) ) {

    p_current = (PAGE *)iter->data;

    if (s_page_objects (p_current)) {
      return_status = return_status +
        s_check_symbol (pr_current, p_current,
                        s_page_objects (p_current));
      if (!quiet_mode) s_log_message("\n");
    }
  }

  return(return_status);
}
------------------------>8--------------------------

> 
> If you like you could write a map-lookalike in c and possibly the
> same for apply, but the coder obviously didn't bother. If you want
> elegance, you can do that to a degree in c also.
While C is a powerful language, it is lowlevel enough compared with
Scheme. Our problem with Scheme is often in that we underemphasize it
and use it the same way as an imperative language while it is functional
and hi-level enough one to free us from many non-related tasks.

Cheers,
  Vladimir

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019