From: "David A. Black" Date: 2008-05-09T04:44:22+09:00 Subject: Re: lambda, ->, haskell, and so on Hi -- On Fri, 9 May 2008, ara.t.howard wrote: > > On May 8, 2008, at 10:04 AM, David A. Black wrote: >> Because if the arrow means "I'm pointing", then the {} should be a >> hash > > > > p :that => 'makes absolutely zero sense to me?' > > p :arrows => 'point to rhs, not hashes' > > m{ } > > m = {} > > m = %r{} > > m = %{} > > m = ->{} > > so i don't see the fact that the char or two before a {} meaning is 'must be > a hash' and standing on very firm ground. Have another look at my posts; I didn't say anything general about a character or two before a {}, and I didn't say that everything an arrow points to is a hash. (It's humbling to discover that you would consider it possible that I would believe something so idiotic, though, and I guess that's good for my character :-) In this situation: m(sym: value) the entire expression ->(x){x} (or whatever) plays the role of value. That includes the ->. Therefore, the -> is not serving the role of pointing to anything. It is already being consumed, so to speak, by the fact that it is part of the value expression. We've got a symbol and a value, and nothing but space between them (because -> is part of the value). So if someone sees this: m(sym: ->(x) { x }) and you say that there's a symbol, plus an arrow pointing to a lambda literal, they would presumably subtract the -> from the picture and conclude that the lambda literal to which the arrow is pointing is this: (x) { x } So when the next example comes along: m(sym: "string") the question might arise: why don't strings get an arrow pointing to them when they're in this position? The answer is: *nothing* gets an arrow pointing to it. Lambda literals *themselves* contain the arrow -- at least, something that looks like an arrow, though semantically it isn't one; it's just the first two characters of a lambda literal. So even if I thought the arrow somehow looked particularly nice in that position, I would not consider that to weigh in on the side of having the ->(){} syntax, and I would not think it so visually attractive as to be worth the possible confusion. The point about hashes was, of course, that if someone *did* read the arrow as meaning "pointing to" the rhs, and the rhs consisted of {}, then they would presumably conclude that what was being pointed to was a hash. It's really just another gloss on the same point and has nothing to do with generalizations about => being an arrow or hashes having characters in front of them. Now, if that explication comes across as meaning that 2 should be set equal to 1, or that argument lists should be typed backwards, or anything like that, I think I'd rather not know :-) In the end all of this is really just a minor side-point to the whole ->(){} discussion. David -- Rails training from David A. Black and Ruby Power and Light: INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin INTRO TO RAILS June 24-27 London (Skills Matter) See http://www.rubypal.com for details and updates!