"it"? "#"? ""?
Matthew Adams
matthew at matthewadams.me
Mon Nov 21 07:39:42 PST 2011
One thing that I can't refute is the argument against magic. Using
currently legal Java identifiers ("it", "_") would be magical, so I'm not
really for that, now. However, introducing a new operator like "#" or an
implicit variable (empty string) would make it more obvious to developers
reading the code that implicit closure parameterization is being used here.
I still like the shorter syntax. It also helps when refactoring, since
there's fewer symbols to refactor (in the absence of a modern IDE, of
course).
-matthew
On Mon, Nov 21, 2011 at 9:16 AM, Richard Warburton <
richard.warburton at gmail.com> wrote:
> On 21/11/11 15:06, Matthew Adams wrote:
> > Hi Remi,
> >
> > I don't understand what you're trying to say. Are you saying that
> instead
> > of "it", "#" or empty string (implicit closure param), "_" could be used
> as
> > an implicit closure param? If so, then Brian seems to have shot that
> down
> > in his last email (no Scala wunderbars). If not, please explain further.
>
> I think what he means is that you can use the underscore character as a
> one character variable name. So the example:
>
> root.listFiles(_ -> _.lastModified()<= before);
>
> means the same thing as say:
>
> root.listFiles(x -> x.lastModified()<= before);
>
> So if you were to want wunderbars then you'be able to write something like:
>
> (_.doSomething())
>
> but if you don't have them you can still write:
>
> (_ -> _.doSomething())
>
> ie the best you're doing is saving the user typing 5 characters
> including whitespace, or 3 excluding whitespace. The decision makes a
> lot more sense to me after this argument has been explained.
>
> regards,
>
> Richard
>
>
--
@matthewadams12
mailto:matthew at matthewadams.me
skype:matthewadams12
yahoo:matthewadams
aol:matthewadams12
google-talk:matthewadams12 at gmail.com
msn:matthew at matthewadams.me
http://matthewadams.me
http://www.linkedin.com/in/matthewadams
More information about the lambda-dev
mailing list