Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #5602
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Passing a Method Name to a Method |
| Date | 2011-06-23 14:40 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <p8c7075nv5qir36d0hap12ulsks1opn5b4@4ax.com> (permalink) |
| References | <81h4075t4gfjglji1n033rb20025ebho68@4ax.com> <itthle$993$1@speranza.aioe.org> |
On Wed, 22 Jun 2011 16:00:46 -0400, "Fuschia, President-Elect of the
Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> wrote:
>On 22/06/2011 3:46 PM, Gene Wirchenko wrote:
>> Dear Jav'ers:
>>
>> Maybe I will find this after searching more, but so far, no good.
>>
>> I want to pass a parameter of a method name to another method.
>>
>> N.B.: I do not want to pass the method name as a string. I want
>> to pass it as a pointer / reference / whatever term is used for this
>> in Java.
>
>Unfortunately, you can't do this easily or efficiently (you'd need to
>use the Reflection API's Method objects) in Java; what you really want
>is a functional language like Clojure or Scala.
>
>If you really must use Java, define an interface that ThisWay and
>ThatWay can be instances of and which specify a parse method, and pass
>an instance to the parser class's method. (The so-called "strategy
>pattern".)
The reason why I want to do this is to check speed of
implementations in Java. Obviously, I have to use Java to test Java
impementations.
I am writing a preprocessor and need to implement a simple
parser. It has to recognise identifiers. The characters allowed for
identifiers vary from language to language. I have the character set
configurable.
The question is which is the best way to implement the function
that returns whether an input character is in the set of identifier
characters. There are three ways that I want to test:
Stuff them in a String and access sequentially.
Stuff them in a String and access with a binary search.
Stuff them in a Treeset.
The outer parser code will be the same. The only difference will be
which character-checking method will be called.
I suppose I am going to end up doing cut-and-paste to make my
test program.
Sincerely,
Gene Wirchenko
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Passing a Method Name to a Method Gene Wirchenko <genew@ocis.net> - 2011-06-22 12:46 -0700
Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-22 16:00 -0400
Re: Passing a Method Name to a Method Gene Wirchenko <genew@ocis.net> - 2011-06-23 14:40 -0700
Re: isIdentifierCharacter (was: Passing a Method Name to a Method) Gene Wirchenko <genew@ocis.net> - 2011-06-23 16:09 -0700
Re: Passing a Method Name to a Method markspace <-@.> - 2011-06-22 14:14 -0700
Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-22 22:59 -0400
Re: Passing a Method Name to a Method blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-06-23 17:49 +0000
Re: Passing a Method Name to a Method markspace <-@.> - 2011-06-23 11:22 -0700
Re: Passing a Method Name to a Method blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-06-24 19:15 +0000
Re: Passing a Method Name to a Method Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-22 22:09 -0400
Re: Passing a Method Name to a Method Gene Wirchenko <genew@ocis.net> - 2011-06-23 09:07 -0700
Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-23 13:43 -0400
Re: Passing a Method Name to a Method Nebulous <nebulous99@gmail.com> - 2011-06-23 13:57 -0700
Re: Passing a Method Name to a Method Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-24 07:28 -0400
Re: Passing a Method Name to a Method blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-06-23 17:53 +0000
Re: Passing a Method Name to a Method Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-22 22:30 -0400
Re: Passing a Method Name to a Method Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-23 09:06 -0300
Re: Passing a Method Name to a Method Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-23 13:23 -0300
Re: Passing a Method Name to a Method Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-23 09:33 -0700
Re: Passing a Method Name to a Method Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-23 17:53 -0300
Re: Passing a Method Name to a Method Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-23 19:15 -0700
Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-24 01:48 -0400
Re: Passing a Method Name to a Method Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-24 02:20 -0400
Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-25 15:26 -0400
Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-23 13:42 -0400
Re: Passing a Method Name to a Method markspace <-@.> - 2011-06-23 11:32 -0700
Re: Passing a Method Name to a Method Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-23 16:23 -0300
Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-23 15:46 -0400
Re: Passing a Method Name to a Method Gene Wirchenko <genew@ocis.net> - 2011-06-23 16:29 -0700
Re: Passing a Method Name to a Method Gene Wirchenko <genew@ocis.net> - 2011-06-23 14:44 -0700
Re: Passing a Method Name to a Method Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-24 07:48 -0400
Re: Passing a Method Name to a Method Roedy Green <see_website@mindprod.com.invalid> - 2011-06-23 09:43 -0700
csiph-web