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


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

Re: simple method to simulate function pointers in java

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail
NNTP-Posting-Date Fri, 02 Sep 2011 05:18:02 -0500
Date Fri, 02 Sep 2011 03:17:34 -0700
From Patricia Shanahan <pats@acm.org>
User-Agent Mozilla/5.0 (Windows NT 5.2; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0
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
Message-ID <R8KdnSlUPN_GMP3TnZ2dnUVZ_r-dnZ2d@earthlink.com> (permalink)
Lines 29
X-Usenet-Provider http://www.giganews.com
NNTP-Posting-Host 70.230.204.158
X-Trace sv3-TV8yrfDC4D8udi+VojEAGaajn18P1rt3aItFRkV4zz0BuLvitezhBs5e9rQiseNFivb4yAc5P9T6cIj!0rA7ZJBAufkHaJotpzKZSHwzKw0ex3WcfvKFx97pANv2goRP2S6Myo9QI6y5yE87Tjwpg8fjtUtY!59dsfToqBP7/5GJDjzmnodF6SR7kQ2numtUgnsxwbgJ9IE8=
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 1935
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7529

Show key headers only | View raw


On 9/2/2011 1:54 AM, Lino Ferrentino wrote:
> Maybe there are other methods... I use this:
>
> public final class b_callbacks {
>
>      private b_callbacks(){
>      }
>
>
>      public static interface void_f_void{
> 	public void f();
>      }
>
>      public static interface void_f_int{
> 	public void f(int i);
>      }
>
>
> }
...
> For each function pointer type we create an interface.

Why not for each different callback situation? That way, you can use
meaningful identifiers for the interface and the methods.

It will also make your code look and read more like idiomatic Java and
less like a literal translation of some other language.

Patricia

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