Code: Select all
(define table:table)
(while (read-line)
(table (current-line) (length (current-line))))
Another problem here is that iterating over the dictionary seems unnatural for casual programmer:
Code: Select all
(dotree (key table)
(if (eval key) (println (name key) " " (eval key))))
But, despite this, I opine that new dictionary syntax is a good idea. But it should be elaborated a bit. My suggestion:
1. When the default functor is 'nil', it should act almost as in the current version, but prepending underscore to the symbol name. I mean, (table "abc" 123) should create symbol table:_abc, not table:abc. Of course, (table "abc") should return the value of table:_abc too. This is compatible with currently undervalued 'bayes-train' function.
2. New loop construction should be introduced. I suggest the name 'dokeys', but the exact name is not of much value. It should iterate only over the keys starting with underscore, and yield them as strings, not as symbols. With this operator my second example became:
Code: Select all
(dokeys (key table)
(println key " " (table key)))
P.S. This way additional attributes can be hold in the dictionary, not confused with user data. Consider 'total' of bayes functions.