From: Josh Cheek Date: 2012-02-09T09:39:18+09:00 Subject: Re: Using _ like in Scala? --0016e6de1796dd44ea04b87d3db0 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Feb 8, 2012 at 9:57 AM, Robert Klemme wrote: > On Wed, Feb 8, 2012 at 4:30 PM, Josh Cheek wrote: > > On Wed, Feb 8, 2012 at 5:58 AM, Robert Klemme < > shortcutter@googlemail.com>wrote: > > > >> On Wed, Feb 8, 2012 at 3:43 AM, Josh Cheek > wrote: > >> > On Tue, Feb 7, 2012 at 9:15 AM, Robert Klemme < > >> shortcutter@googlemail.com>wrote: > >> > > >> >> > Although what I'd really like would be a syntax for naming inline > >> blocks, > >> >> > then my editor could fold the block body inside the name, something > >> like > >> >> > %w[apple banana orange].each display > >> >> > > >> >> > And it would expand to something like > >> >> > %w[apple banana orange].each { |display -> fruit| puts fruit } > >> >> > >> >> How would the above be derived from the line further up? > >> >> > >> > The name would have no impact on the language, it is still just a > block > >> > which takes one argument. It exists to help the developer (and be > used by > >> > the editor). > >> > >> Hmm... Maybe I wasn't clear enough. I was trying to ask how any > >> automated mechanism could read > >> > >> %w[apple banana orange].each display > >> > >> and know it must make > >> > >> %w[apple banana orange].each { |display -> fruit| puts fruit } > >> > >> from it. I am asking specifically since "puts" is nowhere mentioned > >> in the line above. So even if the syntax would be allowed there would > >> have to be some ruling which leads to an interpretation equivalent to > >> the second line. > >> > >> > > Not sure about other editors, but TextMate knows what context it is in if > > you write something like `[].each { |e| }` put your cursor before the e > and > > press C-P, it tells you variable.other.block.ruby. So it knows when it is > > in block paramaters, it would just need to then understand that within > this > > context, if it sees something like `|name -> var|` that "name" is the > name > > of this block, and then just allow for block folding. It actually already > > does all this > > https://s3.amazonaws.com/josh.cheek/images/scratch/block_folding.png but > > instead of showing '...' it could show 'name ...' > > So you are talking about an editor feature and not a language feature? > I am starting to get an idea of where I misunderstood you... :-) > > Yes, what I want is an editor feature (it's also a cognitive aid, even without an editor to take advantage of it), but it requires a language feature to enable. --0016e6de1796dd44ea04b87d3db0--