delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2020/12/01/21:47:36

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
X-CMAE-Analysis: v=2.4 cv=YI9adTKx c=1 sm=1 tr=0 ts=5fc6fb62
a=+cj0cO56Fp8x7EdhTra87A==:117 a=/4BarUKgonoPK4v6kxPF1g==:17
a=9+rZDBEiDlHhcck0kWbJtElFXBc=:19 a=IkcTkHD0fZMA:10 a=zTNgK-yGK50A:10
a=2XxB4mUaAAAA:20 a=j5nqAba_AAAA:8 a=jP1O_3UPaP7ZrVK_FNIA:9 a=QEXdDO2ut3YA:10
a=G3NsWhPI6ntz9aATFwJT:22
X-SECURESERVER-ACCT: glimrick AT epilitimus DOT com
Subject: Re: [geda-user] SAB processing patches
To: geda-user AT delorie DOT com
References: <e4ff3c96-939b-a93e-a32f-5e938b6daa63 AT epilitimus DOT com>
<alpine DOT DEB DOT 2 DOT 21 DOT 2011302045040 DOT 2894 AT nimbus>
<20201130220505 DOT 0AE4282C54FD AT turkos DOT aspodata DOT se>
<7c75ed03-456c-b408-8b50-0448f6b3a04f AT epilitimus DOT com>
<alpine DOT DEB DOT 2 DOT 21 DOT 2012011606400 DOT 6785 AT nimbus>
From: "Glenn (glimrick AT epilitimus DOT com) [via geda-user AT delorie DOT com]" <geda-user AT delorie DOT com>
Message-ID: <1b2c64b3-6a36-c1f3-dd54-bb583c6bea17@epilitimus.com>
Date: Tue, 1 Dec 2020 18:26:30 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Firefox/60.0 SeaMonkey/2.53.3
MIME-Version: 1.0
In-Reply-To: <alpine.DEB.2.21.2012011606400.6785@nimbus>
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - a2plcpnl0121.prod.iad2.secureserver.net
X-AntiAbuse: Original Domain - delorie.com
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - epilitimus.com
X-Get-Message-Sender-Via: a2plcpnl0121.prod.iad2.secureserver.net: authenticated_id: glimrick AT epilitimus DOT com
X-Authenticated-Sender: a2plcpnl0121.prod.iad2.secureserver.net: glimrick AT epilitimus DOT com
X-Source:
X-Source-Args:
X-Source-Dir:
X-CMAE-Envelope: MS4xfCSzyzeGG3rHLQxqvJaYoy4WTQnyzeiirSaMGdZsbDo72HDD5e4hFG1hVo9pjUQ0wzJZxW2JcQFm8wHf5lgSVAbVkkRawN1nf0TYkO58+E2EIHMwa0mo
45WwS2u1xLcdgaGnrXGeyRe5fiF45Yi1qF557AyETxcg4dvCvMCwB/BRXGkB7gtgCrAXncdMjLGiMf9Y8HPRO5dfNZjP/i68rgYUt5+nofcgzd6mkLR3hzU3
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

Roland,

Roland Lutz wrote:
> I have fixed the remaining formatting issues as I encountered them:
>
>     https://github.com/rlutz/geda-gaf/commits/glenn-sab

So I'm stumped (or maybe just dense, the way this day has gone...) My
repository was pulled from git.geda-project.org and I named my branch
just sab. So how do I pull your changes into my branch so I don't send
you a patch that undoes all your fixes?

>
> So here's the next batch of feedback.  I still haven't got to the core
> of it (like "does this make sense" and "is this implemented in a way
> that's copasetic with the rest of gEDA/gaf"), but I'll get there
> eventually.
yes and yes?
>
> - Most things in gEDA/gaf are case-sensitive, so it makes sense to treat
>   SAB arguments as case-sensitive, as well.
>
Hmm...okay. so no str.lower in gnetlist and netlist.py?

> - getlist isn't designed for backends to change component/package names,
>   much less blueprint names.  This may work, or it may not.  If you need
>   to rename things, it's better to use a filtered component/package list
>   instead (see the SPICE backends for an example).
>
Not entirely sure I understand this one. Some general points:
1. I think maybe I am looking at gnetlist in a more general context of
"a tool to work with gaf.netlist.netlist" rather than just "a tool to
generate netlists" if that makes sense.
2. The backend isn't changing anything. A script executed by SAB can but
that happens before the backend is called.

Now assuming we are talking about modify_refdes:
3. modify_refdes is not intended to be a part of the "official" code
base, but rather an example script which is why it is in the examples
directory rather than the mainline code.
4. My default position is the user is always right so if the user
decides to run a script which changes their refdes then so be it, it's
not for me to tell them they shouldn't.
5. At least for the specific case of spice-sdb (and by extension the new
xspice backend I am working on, which is derived from spice-sdb) you
have to change the blueprint refdes to have any effect because that is
what spice-sdb uses for the refdes and ignores the higher levels.

> - You don't need "nobase_" on your "example_DATA" target (you don't have
>   files in subdirectories), but it doesn't hurt, either.
>

okay, noted. I wasn't familiar with how automake handled python so I
just copied a Makefile.am from another directory and hacked. It worked
so I just left it and moved on.

> - Fixes to existing code (like the memory leak in s_slot.c) should go
>   into a separate patch.
>
Noted
Valgrind shows several others, actually it shows lots but most are in
linked libraries not in geda/gaf. I only fixed this one because I was
right there working.

>
> - Header files (especially public ones) should only include those other
>   header files which they minimally require in order to work.  AFAICT,
>   for "sab.h", this would be just "struct.h".
>
Agreed. I'll need to look to be sure but the extras may well be left
over cruft. I know there was a reason I put them there I just don't
recall if that reason is still valid.

> - Don't assign variables inside function calls unless you have a good
>   reason to do so.  Assigning from "strtok" inside "while" in sab.c is
> one
>   of the few cases where this is ok (as the assignment can't be put on a
>   separate line without hurting readability); most other cases are not.
>
<sigh> I always think I have a good reason! B)

> - "TOPLEVEL *" variables are called "toplevel" (all lower-case) in the
>   existing code, so it's a good idea to follow this convention for new
>   code, as well.
>
on the todo list.

>
> - gEDA/gaf Python code should reside within the "gaf" top-level package.
>   You basically have two choices for organizing the SAB code: either
>   (1) have individual sub-modules of gaf by placing the code files in
>       "xorn/src/python/", then import "gaf.sab" and call
>       "gaf.sab.process", or
>   (2) group the SAB source as a sub-package by placing the code in
>       "xorn/src/python/sab/", then import "gaf.sab.sab" and call
>       "gaf.sab.sab.process"
>   I'd go with the first option, but either way is okay.
>
okay, I'll move it, #1 looks cleaner to me.

> - Don't re-define "process" in "sab/__init__.py".  There is some point
>   in doing this for overloaded or publicly-visible functions, but here
>   it just confuses things.
>
noted but moot once I move sab to gaf

> - You are processing the "--sab-context" command-line argument in
>   "netlist.py", so it is not necessary to process it in "gnetlist.in",
>   as well.  You can just pass it through unchanged.
>
yeah this is a bit of leftover. I actually wrote it in gnetlist first
and had a more restrictive syntax in netlist.py and then it occurred to
me that xorn netlist could be called independently and so I needed to do
it there as well. I'll look at it and make sure there's nothing else I'm
doing there and change it if not.

> - User-visible messages should be wrapped in _("...") in order to be
>   translatable.
>
okay

> - Since you use the tuple (order, action, parms) in multiple places, it
>   may be worth defining a collections.namedtuple for that purpose.
>
I'll look at it

> - Don't use something like 1000000000 as a special value.  If you have
>   to store the absence of a value in-band, use something that cannot
>   ever occur as a valid value, like -1 or None.  (And if you *really*
>   have to use a magic value somewhere, please define it as a constant.)
>
Here there was actually a reason to do it this way. By assigning a large
positive number as the *default* order number, when I sorted them all
the unordered actions end up at the end of the list naturally. But I can
certainly make it a constant. The alternative was to have two lists, the
ordered actions and the unordered ones which I really don't like.

> - In modify_refdes.py, the variable "refdes" is either a list or a
>   string.  Since the expression "'C' in ..." works in both cases, I
>   suggest replacing "list(levels.upper())" with "levels.upper()".
ummm....let me look at this in more detail and get back to you.

>
> - You don't need types.StringType and types.ListType;
>   "isinstance(..., str)" and "isinstance(..., list)" work just fine.
>
okay, did not know this

> - Using "dir(m)" to determine whether a variable is defined in a module
>   feels a bit too hacky.  I'm not sure yet how I'd prefer this to be
>   solved; if you absolutely have to make the code depend on whether or
>   not there is such a variable, use it and catch an AttributeError.
>
For me coming from a C/C++ background exceptions are supposed to be for
exceptional, i.e. unpredicatable and serious, cases not alternate cases.
So to me the natural path is to check and proceed accordingly rather
than assume and deal with the consequences if you are wrong. Using
exceptions here strikes me as hacky. Also from an execution perspective
it is more efficient to test rather than use exceptions since there is
no stack unwinding. At least at this point, most backends do not have
SAB_CONTEXT (one of the two cases I think you are referring to) so the
exception pathway would be the most likely to get tripped. But...

If having read all that you still aren't convinced, I will change it and
shudder every time I look at it. Looks like one of us is going to have
to live with the heeby-jeebies on this one. :)

> - Instead of:      ''.zfill(4 * indent).replace('0', ' ')
>   you can just do: '    ' * indent
>
okay, again did not know that.

> - Bonus points for using str.partition!  I didn't know that one.
>
Now if I could just get my tractor started...

Glenn

- Raw text -


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