Mail Archives: geda-user/2015/10/17/17:56:17
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.
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.
Regards,
/Karl Hammar
-----------------------------------------------------------------------
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden
+46 173 140 57
- Raw text -