Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #7528

Re: simple method to simulate function pointers in java

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!cleanfeed1-a.proxad.net!nnrp15-2.free.fr!not-for-mail
Date Fri, 02 Sep 2011 11:56:26 +0200
From Mayeul <mayeul.marguet@free.fr>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1
MIME-Version 1.0
Newsgroups comp.lang.java.programmer
Subject Re: simple method to simulate function pointers in java
References <94e54cff-4dab-4c82-ade8-736174705e51@s2g2000vby.googlegroups.com>
In-Reply-To <94e54cff-4dab-4c82-ade8-736174705e51@s2g2000vby.googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Antivirus avast! (VPS 110902-0, 02/09/2011), Outbound message
X-Antivirus-Status Clean
Lines 27
Message-ID <4e60a772$0$691$426a74cc@news.free.fr> (permalink)
Organization Guest of ProXad - France
NNTP-Posting-Date 02 Sep 2011 11:52:50 MEST
NNTP-Posting-Host 88.183.206.187
X-Trace 1314957170 news-1.free.fr 691 88.183.206.187:1553
X-Complaints-To abuse@proxad.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7528

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar


Thread

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