replacement of short functions by their definitions andother code cleanups
Subject: replacement of short functions by their definitions andother code cleanups
From: Daniel Lakeland
Date: Sat, 5 May 2007 10:56:38 -0700
On Sat, May 05, 2007 at 12:01:54PM -0400, Viktor T. Toth wrote:
> I didn't mean to suggest that format or intern need to be tested. What I did
> mean to say is that during debugging, instead of testing an expression that
> consists of three symbols (in the form of (concat arg1 arg2)) one now needs
> to verify that an expression comprising twice as many symbols and two
> nesting levels (that is, (intern (format nil "~a~d" $idummyx n))) is
> correct.
Without being familiar with maxima internals, I respectfully offer the
following suggestion based on general software development principles.
It seems that this particular case involves the construction of a
symbol in a specific way for a specific purpose, and that this is a
common sort of thing to do in the code. It appears to me that the fact
that the symbol is concatenated is an implementation detail which
might be best abstracted away.
One of the things that often occurs in lisp is that we use standard
data types to make abstract data types. Sometimes this is convenient,
but at other times we break the abstraction and screw things up (a
typical example is implementing LIFO queues with push and pop, and
then at some other point in the code sending the list to a function
which treats it in some way other than queuelike).
May I suggest that Andreas try to identify ways in which symbols are
used as distinct abstract data types, and then we create a set of
convenience functions with names that describe the abstract operations
rather than the implementation details. We could agree on those
changes through a discussion and then implement them to gain
readability and standardization.
I agree that (concat arg1 arg2) is more readable than (intern (format
nil ...)) but even more transparent is something like (numbered-symbol
symbol index) which could of course be implemented as (intern (format
...)) or any other efficient standard method.
--
Daniel Lakeland
dlakelan at street-artists.org
http://www.street-artists.org/~dlakelan