Re: First shot at lisp mini-app - How to make it lispy and not lisp-c
- From: Kenny Tilton <ktilton@xxxxxxxxxx>
- Date: Wed, 13 Apr 2005 21:28:07 GMT
jonathon wrote:
The original app is in Python with GTK as the interface. It maintains a list of accounts and their starting balances. Transactions are saved in a list in an object called the TransactionManager (TM).
At reconciliation time, each account queries the TM for transactions referring to said account. The amount is extracted from the transaction, and added to (or subtracted from) the balance. Simple.
First, in Python, when each account object is created, it receives a reference to the TransactionManager. In Lisp, should this just be a global variable that each account object calls when needed, or should it be stored in a slot within the account object? What precedent would there be for this kind of decision?
I am not sure why the object has to know the TM. The code posting transactions should know that. Sounds like you are trying to make account objects self-sufficient for some reason. Anyway, I would have a slot for TM in the Account class only if I planned to have several TMs, to have Account instances accept transactions from only one TM, and if my logic was going to be regularly posting to multiple accounts managed by different TMs. ie, Hard to imagine.
But this is all OO design, not Lisp vs. Python.
Second, what can I look for that would be an indication of too much like Python or C, where I should try to be more Lisp-ish, such as using macros, closures, etc?
You should consider writing a macro if you find yourself writing repeated patterns of code (boilerplate) which cannot be functions because they wrap variable chunks of code. Note that a closure containing the variable code could be passed to a function instead of using a macro, so a macro just looks a little cleaner.
kt
-- Cells? Cello? Cells-Gtk?: http://www.common-lisp.net/project/cells/ Why Lisp? http://lisp.tech.coop/RtL%20Highlight%20Film
"Doctor, I wrestled with reality for forty years, and I am happy to state that I finally won out over it." -- Elwood P. Dowd
.
- References:
- Prev by Date: Re: First shot at lisp mini-app - How to make it lispy and not lisp-c
- Next by Date: Re: Why Lisp instead of Scheme?
- Previous by thread: Re: First shot at lisp mini-app - How to make it lispy and not lisp-c
- Next by thread: Re: Is there an efficient way to get file length w/o reading file?
- Index(es):
Relevant Pages
|