From: Phil Tomson Date: 2005-10-13T16:41:53+09:00 Subject: Re: Default argument values for blocks Christophe Grandsire wrote: > En r�ponse � David A. Black : > > > > But it's so arbitrary. Surely there's no general principle of "being > > used to" a given punctuation mark that makes it acceptable for > > something like this. > > > > No, but do you really want to have "->" instead? I think the other option is to pass on the whole idea of default arguments to blocks for now if we can't get the nice lambda {|foo='bar'| puts foo } sort of syntax to work. The idea could be resurrected later when we have a better parser technology. Why open the door for this arrow operator for this very special (and likely very rarely used) case. > > > I don't mean to jump on your idea specifically. The whole thread > > seems to be about which arbitrary bit of punctuation might be least > > ugly. I'm totally unconvinced that default values for block variables > > are worth doing any of them. > > > > The problem is that default values for blocks *are* now in Ruby 1.9, and > thus are probably going to be in Ruby2, 1.9 is a testing ground for ideas for Ruby2 (at least that's how I understand it). I don't think that everything in 1.9 (as it currently stands) will be exactly as it is in 2.0. > and use right now the ugly "->". > If they are going to be there, let's have at least a non-intrusive > syntax. Yes it's arbitrary, but just as much as using : for symbols and > @ for instance variables. At the end of the day, every syntax in a > language is a matter of choice and convo ention, i.e. it's arbitrary. Sure that's true, however, it doesn't seem like a good idea to introduce a whole new syntax to support a feature that seems to have limited utility. Especially when the new syntax essentially introduces a new and very different way to define blocks (a central feature of Ruby). > > I also don't really see why blocks arguments should have default values. > But if we're going to have them, at least let's have an OK syntax for > them, instead of an ugly beast. As I said above, I think that if we can't have the syntax that most everyone agrees is the most pleasant and the one which causes the least disruption ( {|foo='bar'| } ) in that it doesn't introduce a special case then perhaps we should forgo the support for the feature until we can get the syntax that fits best with the way things are done now. I'd just hate to see this '->' thingy introduced and in all the Ruby books and then someone comes along and figures out how to parse the pathological case: {|foo=a|b| } (something very hard and perhaps impossible in yacc, but who knows what some yacc wizard might be able to come up with?). Then what? do we deprecate '->'? Probably not, because there will be code out in the wild that depends on it. At that point we have to live with it. Phil