LtU Forum

Jakarta Commons Monad, er, Chain

From Jakarta Commons Chain:
A popular technique for organizing the execution of complex processing flows is the "Chain of Responsibility" pattern, as described (among many other places) in the classic "Gang of Four" design patterns book. Although the fundamental API contracts required to implement this design patten are extremely simple, it is useful to have a base API that facilitates using the pattern, and (more importantly) encouraging composition of command implementations from multiple diverse sources. Towards that end, the Chain API models a computation as a series of "commands" that can be combined into a "chain".
Is it just me, or the Java world has discovered (an ad-hoc, informally-specified bug-ridden slow implementation of) monads?

On a serious side, it would be interesting to hear opinions of the developers.

Elegant Method of binding a function variable

I'm trying to bring myself up to speed on LISP/Scheme and am having one of those days when my brain cell has migrated to another dimension.

I have the following code(given in Scheme):

(begin
(define x 5)
(define (incx n) (+ x n))
(print (incx 2))
(define x 4)
(print (incx 2))
)

The first print will return 7, the second 6.

What I want is for the x in incx to be permanently bound to the first definition (5), so that I get 7 in both calls to incs.

I can do it by assigning x to another name (_x, say) and using that, but I would like a more elegant method of doing it - particularly one that doesn't involve creating an alternative name.

All ideas gratefully received.

Stuart

Geometric Algebra

Shamelessly abusing LtU, I want to point out Geometric Algebra (for those who haven't come across it and would find it interesting.) Some BS rationalizations for why this is appropriate for LtU are: GA is applied to aspects such as computer graphics and computer vision also there's this quote on Leo Dorst's page (which is moving to here): "It is going to be the way computer science deals with geometrical issues." More PLT specific is the design and implementation of libraries, DSLs, and/or software for GA; implementations greatly benefit from compile-time (or even runtime) specialization. For example, Jaap Suter's C++ Clifford library uses template metaprogramming to this end.

However, the real reason I'm posting this is that there are quite a few intelligent people here; I know that at least some are interested in things beyond computer science, and I genuinely think they'd benefit from and value geometric algebra.

Leo Dorst's page is more directed toward computer scientists while David Hestene's page (the first link) is more physics biased.

Curry/Howard and Disjunction

Whilst tralling for Propositions-as-Types references a question arose about the difference between disjunction in propositional logic calculi and sum-types in PLs.

To the best of my knowledge Curry/Howard makes a connection between the 2 concepts even though disjunction is an inclusive-or and sum-types are exclusive, e.g.

A v B ~= A | B | A x B

Am I missing something?

Is choice disjunction in CL also exclusive?

Parsing and syntax reordering

I been doing some programming language design and I ran into something that I am sure as a name, and I thought I would ask too see if anybody could tell me what it is.

I found that the two syntaxes have the same effect (at least the way that I think of languages):

def x <-> x
defun x y z <-> x(y) z
set x 4 <-> x = 4
add x 4 <-> x += 4

ie. the first defines a variable x in the symbol table, the second defines a function x with an arguement y and a body z, etc.

Now the question is: what is the name of a parsing and reordering scheme for transforming the form on the right to the form on the left? I'm not sure if I am using the correct terminology, but basically I'm looking for the algorithm that could be used to convert tokens (or a parse tree maybe?) from the form on the right to the form on the left.

Any help appreciated.

--
kruhft
kruhft.blogspot.com

Waste your CPU-resources on programming challenge

Al Zimmermann's Programming Contests has come up with a new problem that you can try to solve:

Pack n non-overlapping circles with radii from 1 to N into as small a circle as possible.

Try to find the best solution by mid January.

More info here.

The Type-System-Feature-Creep Death Spiral

(This is my first post on LtU, so please tell me if I do anything wrong!)

I've been chewing on this question for a while: How did Glasgow Haskell's type system get so complex? Miranda had a relatively simple Hindley-Milner-style type system. It could do a lot, so people started applying it to more complex tasks, and eventually bumped up against limitations. Haskell added type classes, and they overcame many of these limitations. After a few more iterations of this, we have multi-parameter type classes with functional dependencies. Similar extensions have occured across the language, though few as dramatic as the type class situation.

Haskell's extended type system is Turing-complete. This is rather disturbing, because now Haskell is not one language, but two; one on each side of the :: sign.

Would adding basic data types like lists and integers to the type system be a useful extension? Probably; it would assist with doing compile-time computation, something that many Haskellers have been (ab)using their type system for. How about adding I/O capabilities to the type system? Could come in handy. Who's to say what you can and can't do with types?

The conclusion, chillingly, is that carrying the type system idea to its logical conclusion would leave us with two languages, each with the same capabilities. Each time you added something to one language, you would want to add it to the other. You would have to update the compiler in two places. Any language design effort would be doubled.

This is an extreme example of what could happen, of course, but it definitely makes you ask: Is there a better way? Lisp has shown us that preprocessing code with code in the same language is a big win, both in terms of simplicity and expressive power. I propose that we do the same thing with the type system, and, in fact, that a type system will not be satisfactory until it is the same as the language it types.

I wish I had a paper to present on this; I don't. It just hit me an hour or so ago, and I need feedback on the idea before I can write a paper. So: What do you think? I am I totally off-target? Have you been thinking on the same lines, and, if so, have you got any more specific ideas?

Finding Application Errors Using PQL: A Program Query Language

A number of effective error detection tools have been built in recent years to check if a program conforms to certain design rules. An important class of design rules deals with sequences of events associated with a set of related objects. This paper presents a language called PQL (Program Query Language) that allows programmers to express such questions easily in an application-specific context. A query looks like a code excerpt corresponding to the shortest amount of code that would violate a design rule. Details of the target application's precise implementation are abstracted away. The programmer may also specify actions to perform when a match is found, such as recording relevant information or even correcting an erroneous execution on the fly. We have developed both static and dynamic techniques to find solutions to PQL queries. Our static analyzer finds all potential matches conservatively using a context-sensitive, flow-insensitive, inclusion-based pointer alias analysis. Static results are also useful in reducing the number of instrumentation points for dynamic analysis. Our dynamic analyzer instruments the source program to catch all violations precisely as the program runs and optionally to perform user-specified actions. We have implemented techniques described in this paper and used this combination of static and dynamic analysis to successfully find 206 breaches of security and important resource leaks in 6 large real-world open-source Java applications containing a total of nearly 60,000 classes.

I saw the talk to this paper two weeks ago at OOPSLA two weeks ago and liked it very much. In a sense, I would consider it as a new application for aspect-oriented techniques.

Would LISP/FP help here?

Hello..

I am working on tools aimed at chips design (I'm hardware designer). I have written a very usefull front-end that allows me to write things like: 'a wire b wire add r wire assign;'
This in actually an adder. To be clearer, 'wire' has 1 argument while 'assign' and 'add' have 2. (I am using a HP-like notation as the parsing is easy using stacks).

My tool creates a abstract tree that is being specialized depending on the domain: functional simulation, register-level simulation, simulation+timing, documentation,...

For instance, if I want to do timed simulation, the tool(C++) will use the abstract tree to create a new tree with nodes taken from classes implementing timed simulation.

It works fine, but I find it hard to add new features (I won't give any details here as this would be too much details). I was wondering whether FP would be of any help to create and/or specialize the abstract tree to a specific application? Any idea, pointers to example implementing something like this would be appreciated.

I am asking this because I've come to believe I would be more helped by a language like LISP than by C++..

Thanks,
Laurent

Pre-LINQ: rich object management in your PL

The definition and long-term management of data in complex systems requires extensive support, including high-level type and behavior modeling, persistence, query-based and navigational access, consistency management, and concurrency control. Traditionally, some of these capabilities have been provided by programming languages (e.g., semantically rich type and behavior models and navigational access), while others have been provided by database management systems (e.g., persistence, queries, and concurrency control). No language or database has provided the full set of required capabilities, however.

We have developed a different approach to addressing the object management needs of complex applications. This approach eliminates the dichotomy between "programming language" and "database"' objects, thus allowing the full set of language and database capabilities to be applied equally to all objects.

I have a smattering of understaning of LINQ; this paper appears to me to describe further functionality than what would be in LINQ at least at first. Apparently implemented as Pleiades for ADA, although that doesn't appear to be available any more.

XML feed