Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #7528
| Date | 2011-09-02 11:56 +0200 |
|---|---|
| From | Mayeul <mayeul.marguet@free.fr> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: simple method to simulate function pointers in java |
| References | <94e54cff-4dab-4c82-ade8-736174705e51@s2g2000vby.googlegroups.com> |
| Message-ID | <4e60a772$0$691$426a74cc@news.free.fr> (permalink) |
| Organization | Guest of ProXad - France |
On 02/09/2011 10:54, Lino Ferrentino wrote:
> Maybe there are other methods... I use this:
>
> [Functor interfaces]
Well yes, that's pretty much it.
Note you do not have to declare these interfaces as nested in a class.
You may, if you think it makes matters clearer, but you don't have to.
public interface PettingStrategy {
void pet(Dog dog);
}
Note that it will usually lead to unclear terminology when you think in
terms of 'function pointers'. Function pointers are a general-purpose
language mechanism, which happen to not exist in Java. No need to pursue
it to the end.
Whenever you have a need for a mechanism of the sort, there is a
precise, well-defined, task you need to perform with this mechanism. You
should create interfaces designed to perform this task, and name these
interfaces and their methods accordingly. This will make your programs
clearer.
--
Mayeul
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
simple method to simulate function pointers in java Lino Ferrentino <lino.ferrentino@gmail.com> - 2011-09-02 01:54 -0700
Re: simple method to simulate function pointers in java Mayeul <mayeul.marguet@free.fr> - 2011-09-02 11:56 +0200
Re: simple method to simulate function pointers in java Patricia Shanahan <pats@acm.org> - 2011-09-02 03:17 -0700
Re: simple method to simulate function pointers in java Lino Ferrentino <lino.ferrentino@gmail.com> - 2011-09-02 05:11 -0700
Re: simple method to simulate function pointers in java Arne Vajhøj <arne@vajhoej.dk> - 2011-09-05 21:21 -0400
Re: simple method to simulate function pointers in java Roedy Green <see_website@mindprod.com.invalid> - 2011-09-02 07:43 -0700
Re: simple method to simulate function pointers in java Arne Vajhøj <arne@vajhoej.dk> - 2011-09-05 21:24 -0400
Re: simple method to simulate function pointers in java Lew <lewbloch@gmail.com> - 2011-09-05 19:00 -0700
Re: simple method to simulate function pointers in java "John B. Matthews" <nospam@nospam.invalid> - 2011-09-06 13:39 -0400
csiph-web