Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×

Comment Re:I'm disappointed (Score 1) 434

Do you consider something like BigDecimal in Java to be a variable?

Surprisingly enough, this restriction in Erlang is compensated for quite handily through it's functional programming approach. It took me a while to grok it, and I'm still no expert, but it's definitely off the beaten path and quite powerful. I've applied a number of techniques I learned from a couple of years of Erlang programming to my work in other languages. It forced me to "think different", and that's not always a bad thing.

Comment But I don't want to be walled in (Score 1) 158

I don't want to be walled in based on what I've looked at before. I like running across off-beat articles on websites that pique my curiosity. It's half the fun of surfing.

This proposal would try to decide what I'm "interested" in, and filter results and pages to that which I've seen before.

That wouldn't be much fun at all!

Comment Re:I'm disappointed (Score 1) 434

Let me try a different tack.

Imagine Java had function pointers added to it. You might be able to do such a thing using introspection, but I'm not sure.

Now define a lambda-accepting method that takes a lambda function as an argument.

The implementation specifies an anonymous method accepting the arguments of the function pointer signature inline with the invocation of the lambda-accepting method. Within the body of that anonymous function you have access to the variables of the enclosing method as well as the members of the method's class.

Because the anonymous method is an inline argument to the invocation of the lambda-accepting method, you can specify more than one lambda as an argument to that method.

With Erlang, everything is based on functions and function pointers, but their syntax and implementation are cleaned up greatly compared to a language like C++ so you have a much harder time hanging yourself.

It's also much lighter weight than a class method override, because you don't instantiate a new instance when the lambda body gets invoked, but pass the existing object instance of it's enclosing method.

Comment Re:Still 32GB barrier (Score 1) 434

For example, it prevents you from reading a binary object larger than 2^32 into memory for subsequent manipulation or serving up from cache. With modern media files, it's quite possible (and even common) to exceed the 2GB file size limit of 32 bits.

Comment Re:I'm disappointed (Score 1) 434

No, I think we're talking about different things.

With Erlang, any function that matches an argument signature can be passed to a function that can take a lambda. But with Erlang, a given function can take more than one lambda at the same time as an argument. The closest analogy I could think of with the Java approach is to override *multiple* methods with a single lambda specification, not jujst one.

So it's not polymorphic in the sense that I think you're describing. It's just a broader-scoped implementation.

For example, you might define one lambda in Erlang that gets the next value from some abstract container to be defined by the programmer. You might define another lambda to compare elements. The lambda-receiving function sort() accepts both, producing a sorted list based on the arbitrary "key" of the lambdas. I don't see any way of doing that with the Java approach, because there is no way to specify multiple lambda arguments for the implementation of sort().

In "normal" Java you could do it by expecting two interfaces for sort()'s arguments, so perhaps you could then specify lambdas of the interfaces, but I'm not sure. I'm pretty sure Java would mandate that you use classes, not interfaces, which kind of limits the generic approach that Erlang offers.

Comment Re:I'm disappointed (Score 3, Interesting) 434

I think the bigger reason they probably didn't do it is that Erlang only lets you assign a variable once, so there are no concurrency issues with read/write of variables. One of the neat side effects of this is that a service/method which takes a lambda argument can be parallelized behind the scenes without changing the meaning of the code execution.

Another thing that puzzles me is that Java lambdas seem to be based on the idea of overriding a method of a class. That seems to me to be a critically limiting way of implementing them vs. function prototypes/templates, as there is no way to specify multiple lambdas being passed to the evaluator.

Comment I'm disappointed (Score 2) 434

I'm disappointed. I expected Lambda functions to be closer to Erlang's implementation, where you can access the variables of the enclosing function/method safely. But perhaps the examples in the article are just too simplistic to show such behaviour.

Slashdot Top Deals

"I don't believe in sweeping social change being manifested by one person, unless he has an atomic weapon." -- Howard Chaykin

Working...