Download presentation
Presentation is loading. Please wait.
1
Pattern-Directed Programming
A style explicitly using pattern-matching against program source names Presentation to be followed by an epilogue on research into an observer-actor style
2
Motivation Languages include a control structure giving effective, procedural interpretations to the means of combination and means of abstraction of the language, e.g. the apply function in Scheme. Augmentations to the control structure of a language along with language-level facilities for invoking control structures either explicitly or implicitily define new styles of programming. Advanced control features such as mechanisms for automatic search and backtracking and applying the operations of propositional calculus to streams of data result in widely divergent styles and idioms for programming. What control mechanisms which have yet to be incorporated into the control structure of a language? Have existing control mechanisms been integrated into a language in both implicit and explicit forms?
3
The Basic Idea Pattern matching exists largely implicitly in the control structures of current languages Merge a pattern matcher with the control structure of an evaluator of a functional language Provide language-level keywords for explicitly invoking the pattern matcher against names in the environment of invocation Take advantage of the characteristic that pattern matching returns multiple values
4
Implementation Strategy
Augment the control structure of a meta- circular evaluator of the functional core of Scheme Add keyword match to match a pattern against names in the environment Extend the evaluation semantics of Scheme to accept match objects in the operator position of an S-expression
5
Blather: The Interpreter
match constructs match objects, a tagged list consisting of names and an associated environment (match) returns match object consisting of all names and the environment in which the names were matched (match <symbol>) returns a match object with all names containing <symbol> (match-object-to-names <match_object>) returns a list of names in a match object (match-object-to-values <match_object>) evaluates names from the match object in the associated environment of the match object (<match_object> . <argument_list>) looks up each name in the match object and applies the result to the argument list concatenating the results into a single result list
6
Noteworty Features As designed and implemented, the explicit invocation of the pattern matcher and the returned match objects proved easily composable with the existing features of Scheme When programming in a uniform style treating all functions as taking a single list as argument, match objects can be used freely throughout a program
7
Possible Uses Any domain in which patterns might be closely associated with code or behaviors represents a possible area of application, for example DNA/RNA and protein folding analysis Patterns represent a possible bridge between symbolic and subsymbolic knowledge, so pattern- directed programs using reflection might be used to retrieve symbolic knowledge from subsymbolic systems
8
Future Work Implement a large system using the pattern- directed style to study the expressiveness, controllability, and comprehensibility of pattern-directed programming Evaluate the fitness of the keywords and special forms of the implementation in the context of a large project, and add language- level features as necessary
9
Epilogue: The Observer-Actor Style
As a second area of research, studied solutions to the problem of unintentional object retention as manifest in situations such as the observer design pattern Resolved to implement a simple object system without aliasing and including a messaging facility in the control structure to shift decisions about actor retirement into the interpretation of messages Planned an observe-act evaluation strategy similar to the read- eval-print strategy of LISP/Scheme Outlined a recursive procedure for computing with nested observer-actors Design was longer than anticipated delaying implementation Hope to finish implementation in a few weeks
10
Thanks
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.