User loginNavigation |
LtU Forum"Practical" advantages of lazy evaluationHi all, regards Near-Concrete Program InterpretationNear-Concrete Program Interpretation, By Paritosh Shroff, Scott F. Smith, Christian Skalka:
Very interesting paper that brings sophisticated higher order analysis to abstract interpretation. The paper proves the algorithm is exponential for certain types of programs, akin to ML type inference, and polynomial for first order programs. They have a working implementation in OCaml. Lambda in C# 3.0Maybe on the edge of being off-topic, but I figure that since this place is called Lambda-the-Ultimate, perhaps questions about lambda in evolving languages might be tolerated. I've been hearing that the next-gen of C# was supposed to add support for lambdas, so I downloaded the beta. Starting out, it looks rather hopeful. delegate int IntToInt(int i);
static IntToInt Factorial =
(n) => n <= 1 ? 1 : n * Factorial(n - 1);
First inconvenience is that I have to declare delegates that match the signature of any lambda functions I want to assign. Wonders if it's possible to do this without having to declare a delegate? More inconvenient is that recursion only works for static declarations. The following is fairly identical to the above, other than the fact that it is an instance variable, but will not compile: delegate int IntToInt(int i);
IntToInt Factorial =
(n) => n <= 1 ? 1 : n * Factorial(n - 1);
So I'm wondering how one goes about getting recursive functions using the lambda syntax? ML does this with the 'rec' attribute keyword but I don't find anything similar in the new C# specs. My own opinion is that there should not be a distinction between named and anonymous functions, though a lot of languages I encounter seem to make this distinction. C# 3.0 doesn't have Python's limitation of being restricted to expressions - control structures can be used: static IntToInt Factorial =
(n) =>
{
if (n <= 1)
return 1;
else
return n * Factorial(n - 1);
};
Nor does it require special application like Ruby's call. But it does seem to have rules about forbidding the reuse of parameter names that are in the scope of the defining body (if X is declared in the surrounding scope, then X can't be a parameter for the lambda function). I'm guessing that the main impetus for lambdas in C# is the new DLinq syntax, so perhaps assigning lambdas to variables in trying to create blocked scoped functions is not a priority. Nested data parallelism in Haskell (video)"At the inaugural meeting of the London Haskell User Group, Simon Peyton Jones of Microsoft Research talks about his current work on nested data parallel processing in Haskell." I think this is very inspiring work! Apologies if this has already been posted. By magnus at 2007-05-26 03:52 | LtU Forum | login or register to post comments | other blogs | 8338 reads
Tom: Piggybacking rewriting on javaThe paper about the Tom language accepted at RTA 07 is available on the net. Here is the abstract:
Le me mention that Tom not only adds pattern-matching features to Java (or other target languages), but also proposes a strategic programming library which really brings rewriting to Java. The proposed pattern-matching algorithm is more powerful than the ones usually present in functional languages though, since it supports associative matching with neutral element and recently introduced antipatterns. It is actively used in both industrial and academic project, including the compiler itself, an implementation of the explicit rewriting calculus and a proof assistant for superdeduction modulo. By polux at 2007-05-25 19:46 | LtU Forum | login or register to post comments | other blogs | 6997 reads
Does these constructs solve the expression problem?While thinking about the expression problem and toying with (toy) language design, a simple solution to the problem came to mind. The expression problem is about extending datatypes and adding functions without recompiling the orignal code, so why not have a simple construct to extend each of these? Every time you add a constructor to an algebraric datatype, you need to extend each of the functions on the type with a case covering the constructor. The two construcs are thus: 1) extend a datatype and 2) extend a function. Addition of completely new functions comes for free in a functional setting. Here is some pseudo-code illustrating the idea:
# declare a new algebraric datatype Expr with one constructor
type Expr:
case CONST(Int)
# declare a new function eval
function eval Expr -> Int:
case CONST(x):
x
# extend the algebraric datatype Expr with another constructor
extend type Expr:
case ADD(Expr, Expr)
# extend the function eval with another case
extend function eval Expr -> Int:
case ADD(x, y):
eval(x) + eval(y)
# declare an additional operation on Expr
function toString Expr -> String:
case CONST(x):
intToString(x)
case ADD(x, y):
eval(x) ++ "+" ++ eval(y)
I realize that the implementation of extendable functions would need indirection (so no inlining), but other than that I don't see any problems with it. My formal education in PL theory is very limited still, and I'd appreciate any comments that visualize weakness in the above constructs, or any references to languages that have similar constructs. Currying != Generalized Partial Application?!I had mistakenly learned that curry was a form of generalized partial application from the paper : Function Currying in Scheme by Jeffrey A. Meunier In my paper I defined curry in Cat as:
define curry : ('b ('A 'b -> 'C) -> ('A -> 'C)) { swap quote swap compose }
Whereas this really should have been called "partial-apply", "papply" or something comparable.
define papply : ('b ('A 'b -> 'C) -> ('A -> 'C)) { swap quote swap compose }
define curry : (('A 'b -> 'C) -> ('b -> ('A -> 'C)) { quote [papply] compose }
Has anyone else made this mistake? It seems to me that I have seen more incorrect definitions than correct ones. P.S. Anyone here interested in the health of Wikipedia (I've given up), I'd suggest fixing the code examples and "intuitively ..." note. Error messagesThis looks interesting -- has anyone had a closer look? SEMINAL: Searching for Error Messages IN Advanced Languages Benjamin Lerner, Dan Grossman, and Craig Chambers
Their system is for OCaml, btw. Personally I find the standard OCaml messages reasonably useful... but I have no idea how much hair is behind them in the compiler. Josh DbC + OPascal == Chrome(Hadn't seen this before, didn't find it mentioned on LtU via the search.)
I'm not sure I'd call a new version of Object Pascal coming from a single vendor "a main-stream language" but Chrome still sounds interesting. Picky libraries, picky languages?STL has some complexity requirements specified. (Dunno how much people really meet them, or what the constant factors are, of course.) I often find myself scratching my head trying to figure out what, if any, specification the Java standard libraries are following in terms of e.g. performance and behavioural contracts. To what degree do people value the idea of providing a standard library for a language that is super well specified w.r.t. things like time and space complexity, suitability for concurrency, behavioural patterns, use of nulls, etc.? (Personally, as a library consumer, I think that would all be the bee's knees.) It sure seems like a rarity. Further, to what degree should such things be available as core concepts in a language? Are various complexity metrics describable in any design-by-contract systems? It would possibly be neat to declare that a method has a certain running time complexity, and then have the compiler and tools chain that information together throughout the call tree (I'm not expecting them to prove the declared complexities). And ways to put assertions or requirements in bounding those values. I've poked around but haven't turned up any great refs, thanks for any info/pointers. I guess to some degree I see this all being aimed at correctness by construction vs. relying too much on post-hoc testing. |
Browse archives
Active forum topics |
Recent comments
8 weeks 4 days ago
8 weeks 4 days ago
8 weeks 5 days ago
8 weeks 5 days ago
9 weeks 2 days ago
9 weeks 2 days ago
9 weeks 3 days ago
9 weeks 3 days ago
9 weeks 3 days ago
9 weeks 3 days ago