User loginNavigation |
archivesFAQ typo
Namely, "langugae" near the end.
Fixing this typo has proved elusive...
*duck* OTOH, it's probably left there intentionally to demonstrate the perils of copy-paste programming ;-) Python metaprogramming with decoratorsThis recipe for using decorators to load data structures caught my eye (thanks to the Daily Python URL) as an interesting metaprogramming technique. Decorators are function transformers that can be applied declaratively to normal Python methods and functions using the much-disputed decorator syntax (see this previous LtU thread). This recipe uses decorators that return the supplied function unmodified, but as a side-effect register it in a dictionary of handlers for various value conversion operations. The decorator code itself is called when the module is loaded, so the dictionary is populated "on demand" at run-time. This makes an interesting contrast with compile-time metaprogramming techniques such as C++ template metaprogramming and the use of code generators and preprocessors. I do not believe that C# attributes could easily be used in a similar way, as unlike Python decorators these receive no information about the entities they are attached to when they are instantiated. StarlogStarlog is a pure-logic programming language designed to overcome some of the problems inherient in traditional approaches to logic programming. Starlog was designed as an alternative approach to programming in pure logic. Many of the failings of other logic programming languages can be overcome using the bottom-up evaluation technique. Bottom-up evaluation avoids problems associated with cyclic relations, and allows side-effects to be performed without compromising the declarative semantics of a program. Using Starlog we advocate a data structure free programming style. That is, predicates in Starlog programs do not contain compound terms for their arguments. This greatly simplifies logic programs and their implementations, lowers the learning curve for new programmers, and forces the programmer to think of all program constructs as relations. |
Browse archivesActive forum topics |
Recent comments
22 weeks 12 hours ago
22 weeks 16 hours ago
22 weeks 16 hours ago
44 weeks 1 day ago
48 weeks 3 days ago
50 weeks 1 day ago
50 weeks 1 day ago
1 year 4 days ago
1 year 5 weeks ago
1 year 5 weeks ago