252 reputation
14
bio website
location
age
visits member for 2 years, 3 months
seen Aug 9 '13 at 2:58

Aug
9
comment British royal succession algorithm
I don't think citizenship matters. However, spouse's religion does.
Jul
28
comment Are closures sufficient to characterize functional programming?
@jozefg: same thing about Referential transparency. CL, SML, OCaml, Scheme, etc. are not referentially transparent. Only Haskell is referentially transparent.
May
25
awarded  Yearling
Apr
17
comment Is a lambda expression something more than an anonymous inner class with a single method?
@StuartMarks: No, you didn't read my answer. I didn't say that each of them can do everything the other does. I said that a lambda has an equivalent anonymous class that is semantically the same. As I already said in comments, this in lambda is a part of the syntactic sugar, and is not a difference in semantics. And about differences in implementation, implementation != semantics. About differences in object identity; object identity is extremely tangential to the functionality of lambdas; nobody checks the object identity of lambdas/anon classes anyway because it is not useful.
Apr
17
comment Is a lambda expression something more than an anonymous inner class with a single method?
@Giorgio: a lambda can't refer to itself internally. A lambda is a more restricted special case of anonymous classes. For example, an anonymous class can have instance variables to store state across calls, and a lambda can't. So lambdas can't do everything that anonymous classes can. But anonymous classes can do everything that lambdas can.
Apr
17
comment Is a lambda expression something more than an anonymous inner class with a single method?
@Giorgio: I am not "proposing" anything. What, exactly, do you disagree with what I said? Yes, the inside of the expression will look different, e.g. we will add a method, and yes, this will need to be converted to OuterClass.this. That does not contradict what I said -- every lambda expression can be converted into a semantically-equivalent anonymous class expression without altering anything outside of that expression. I didn't say that the inside wouldn't change.
Apr
17
awarded  Commentator
Apr
17
comment Is a lambda expression something more than an anonymous inner class with a single method?
@Giorgio: Yes, but the conversion of this into OuterClass.this is part of the process of de-sugaring lambda expressions into anonymous class.
Apr
17
comment Is a lambda expression something more than an anonymous inner class with a single method?
@Giorgio: and what different semantics do they have?
Apr
17
comment Is a lambda expression something more than an anonymous inner class with a single method?
why downvote? what I said is completely correct
Apr
16
revised Is a lambda expression something more than an anonymous inner class with a single method?
added 167 characters in body
Apr
16
comment Is a lambda expression something more than an anonymous inner class with a single method?
Learning that everything can be implemented in terms of lambdas is very instructive and not "esoteric" in my opinion. (However, I guess most "coders" don't care about interesting CS theory.) That doesn't mean that lambdas is special; it just means that lambdas are one type of universal construct. There are others, like SKI combinators. Lambdas are fundamental building blocks in functional paradigms, but maybe something else can be fundamental in another paradigm.
Apr
16
answered Is a lambda expression something more than an anonymous inner class with a single method?
Mar
11
comment Is garbage collection needed for implementing safe closures?
@Giorgio: Let's consider C++, a language without garbage collection but does have safe closures, if you do not capture by reference. A lambda in C++ is just an anonymous functor class, where captured variables are stored as instance variables. So your question is equivalent to "Is garbage collection needed for implementing safe classes?" e.g. if you are asking, how would I capture xyz safely in a closure that may outlive this scope? you can equivalently ask, how would I store it safely in an object which may outlive this scope? The answer to that will answer your original question.
Mar
11
comment Is garbage collection needed for implementing safe closures?
@Giorgio: Right, so I am saying that the "variable"'s lifetime is not extended. The thing that the variable points to is another matter. For things like refs, arrays, lists, and other structures like that, the structure's lifetime is always dynamic anyway, and not tied to any scope. For example, with val a = ref 1, you can then return a from the function; a's lifetime is not extended, but the data structure is still accessible in other scopes. So data structures in SML fundamentally use garbage collection, even without closures. Adding closures does not change anything.
Mar
10
comment Is garbage collection needed for implementing safe closures?
@Giorgio: How about now? Also, in what sense do you find my statement that closures do not need to extend the lifetime of a captured variable incorrect? When you talk about mutable data, you are talking about reference types (refs, arrays, etc) that point to a structure. But the value is the reference itself, not the thing it points to. If you have var a = ref 1 and you make a copy var b = a, and you use b, does that mean you are still using a?No. You have access to the same structure pointed to by a?Yes. That is just how these types work in SML and have nothing to do with closures
Mar
10
revised Is garbage collection needed for implementing safe closures?
deleted 117 characters in body
Mar
10
awarded  Editor
Mar
10
revised Is garbage collection needed for implementing safe closures?
deleted 117 characters in body
Mar
9
answered Is garbage collection needed for implementing safe closures?