On Fri, May 29, 2009 at 8:16 AM, Darrin Thompson <darri...@gmail.com> wrote: > Have we noticed any principles for when/how to use dynamics, tuples, > and combinators together to solve problems?
Factor is still a young language so at this stage we don't have a good set of hard and fast guidelines yet. Your best bet at this stage is to study existing code and see how things fit together, then try writing your own code, share it, and solicit feedback from the community. I hope one day someone can write a book, 'Practical Factor Development', or whatever, that describes all the best practices and potential pitfalls that new developers should know about, but we're not there yet. > For instance, after some false starts I think I've worked out that I > want my little data munger to look like this: > > P" apath" parse-mibor > [ "MlsNum" by-name do-stuff "AnotherCol" by-name do-more whatever ] > with-mibor-bulk-each-record > > with-mibor-bulk will create a new namespace with two variables, one is > an assoc with column names mapped to column indexes (grabbed from the > first array) and the other is an assoc with the current record array. > > by-name will consult those two variables and leave the current > record's data for that field on the stack. This looks reasonable to me. I've realized lately that in some places, I use dynamic variables in a similar way to how Java and C++ people use classes in the case when the class groups methods related to an algorithm, rather than defining a data type (the latter is more the domain of Factor's object system). A vocabulary might define a few symbols, and a set of words which manipulate data stored in variables named by those symbols. The vocabulary will have several main entry points which set up the variables and call private words, or alternatively, a combinator which sets the variables and then calls a quotation in the new dynamic scope. This pattern is used particularly often in the compiler. Slava ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk