This code is really great for someone who has just started Factor. I have a couple general suggestions, but these are all optional things.
First of all, you might want to factor your words out a little more, to make the code more clear. Certain words like, say, (dns-name-read) might be more clear if split into three words, (dns-name-read) and two helpers which are the two three-line bodies of the quotations in the cond statement. Separating them into separate words, with meaningful names, provides more documentation as to what they do and what their arguments mean. This might also be appropriate for dns-name-write. A possible rule of thumb is that words generally shouldn't be more than three lines long (but in a case statement or some cond statements or certain mathematical operations, this just doesn't work out very well). You are using the stack to a fairly deep level in many places. In some places, the reader must keep track of five positions in the stack. The way things are structured, this works out pretty well in your code most of the time, but you might want to consider (in general) storing some things in an array to reduce the number of things on the stack. Again, a rule of thumb which can't always be followed is to have each word keep track of three or fewer things on the stack. The tuple-each abstraction looks really interesting and potentially useful in other cases. However, to get it to compile efficiently using Factor's optimizing compiler, it must be altered somewhat. You might want to look at macros, in extra/macros, to implement this. The idea is that you create a quotation which can be assembled at compiletime, which, when run, does what you want it to do. So you want to make a quotation which'll do the tuple-each action given the array of quotations. This isn't, by itself, enough to work at compiletime; the tuple class is also necessary as a parameter to get the slots. This isn't as bad as it sounds. Think about how terribly dysfunctional tuple-each is if you give it a different tuple class than you're expecting! If you want help in implementing this, ask me. Finally, you may want to change your code to work with some of Factor's newer features. For one, there's a new, terser style of accessors, and it is planned that the old style will be removed. Another change is that delegates will be removed in favor of explicit consultation, currently in extra/delegate. But, overall, this is great. Certainly much cleaner than the first couple Factor libraries I wrote. Dan On Fri, Apr 4, 2008 at 9:00 AM, Maxim Savtchenko <[EMAIL PROTECTED]> wrote: > Hello > > I'm newbie Factor developer. First of all, I'd like to say "thank you > very much" for really great language. Having all the power and > simplicity of Lisp without closing ten or more damn brackets at the > end of each complex function - this is my wet dream from school days. > > I have choosen Factor for my next web-related project. One part of > this project is dynamic DNS server. I think, general DNS library will > be usefull not only for me, so I'd like to share. For now, it is > pretty low-level, only DNS message parsing and generation, but with > two-way name packing. Library is not not yet tested in real-life > environment and may be buggy, but before investing more time into it, > i'd like to show my code to more experienced Factor developers. Am I > doing something wrong? > > Thank you. > > Maxim Savchenko. > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > Factor-talk mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/factor-talk > > ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
