Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #22211 > unrolled thread
| Started by | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| First post | 2013-02-08 14:21 -0800 |
| Last post | 2013-02-09 19:21 -0500 |
| Articles | 16 — 4 participants |
Back to article view | Back to comp.lang.java.programmer
PUT DATA Roedy Green <see_website@mindprod.com.invalid> - 2013-02-08 14:21 -0800
Re: PUT DATA Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 17:34 -0500
Re: PUT DATA Lew <lewbloch@gmail.com> - 2013-02-08 16:13 -0800
Re: PUT DATA Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 19:18 -0500
Re: PUT DATA Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-02-08 20:44 -0400
Re: PUT DATA Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 19:52 -0500
Re: PUT DATA Lew <lewbloch@gmail.com> - 2013-02-08 17:06 -0800
Re: PUT DATA Lew <lewbloch@gmail.com> - 2013-02-08 17:08 -0800
Re: PUT DATA Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 20:09 -0500
Re: PUT DATA Lew <lewbloch@gmail.com> - 2013-02-08 17:16 -0800
Re: PUT DATA Arne Vajhøj <arne@vajhoej.dk> - 2013-02-08 20:36 -0500
Re: PUT DATA Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-02-09 08:14 -0400
Re: PUT DATA Lew <lewbloch@gmail.com> - 2013-02-08 16:10 -0800
Re: PUT DATA Roedy Green <see_website@mindprod.com.invalid> - 2013-02-09 09:54 -0800
Re: PUT DATA Roedy Green <see_website@mindprod.com.invalid> - 2013-02-09 15:49 -0800
Re: PUT DATA Arne Vajhøj <arne@vajhoej.dk> - 2013-02-09 19:21 -0500
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2013-02-08 14:21 -0800 |
| Subject | PUT DATA |
| Message-ID | <i4uah8h7g0ft1r1b3ljsuinat0luq209p8@4ax.com> |
In the olden days PL/I has a output mechanism called PUT DATA Expresses Javesquely it would look like this: out.putd ( xlow, xhigh); It would output xlow=23.4 xhigh=200.0 (There was also a keyword/value input method. It was mainly helpful in debugging.) I could see how you could implement it in a preprocessor or amanuensis, but can you do it with a pure Java method? What if you warp the syntax brutally to hide info with annotations? -- Roedy Green Canadian Mind Products http://mindprod.com The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time. ~ Tom Cargill Ninety-ninety Law
[toc] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-02-08 17:34 -0500 |
| Message-ID | <51157d6d$0$291$14726298@news.sunsite.dk> |
| In reply to | #22211 |
On 2/8/2013 5:21 PM, Roedy Green wrote: > In the olden days PL/I has a output mechanism called PUT DATA > > Expresses Javesquely it would look like this: > > out.putd ( xlow, xhigh); > > It would output > > xlow=23.4 xhigh=200.0 > > (There was also a keyword/value input method. It was mainly helpful > in debugging.) > I could see how you could implement it in a preprocessor or > amanuensis, but can you do it with a pure Java method? What if you > warp the syntax brutally to hide info with annotations? xlow and xhigh seems to be variable names. They do not even exist at runtime for local variables. So: no - impossible. And annotations are put on types not on instances. Arne
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2013-02-08 16:13 -0800 |
| Message-ID | <54cfb631-0b26-4e82-a58d-c9d094f4329e@googlegroups.com> |
| In reply to | #22212 |
Arne Vajhøj wrote: >> And annotations are put on types not on instances. http://docs.oracle.com/javase/7/docs/api/java/lang/annotation/ElementType.html contradicts you. How else would injection work? -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-02-08 19:18 -0500 |
| Message-ID | <511595c5$0$283$14726298@news.sunsite.dk> |
| In reply to | #22216 |
On 2/8/2013 7:13 PM, Lew wrote: > Arne Vajhøj wrote: >>> And annotations are put on types not on instances. > > http://docs.oracle.com/javase/7/docs/api/java/lang/annotation/ElementType.html > contradicts you. > > How else would injection work? ???? X a; X b; what annotation are you suggesting that I use two distinguish between the two X'es? Arne
[toc] | [prev] | [next] | [standalone]
| From | Arved Sandstrom <asandstrom2@eastlink.ca> |
|---|---|
| Date | 2013-02-08 20:44 -0400 |
| Message-ID | <nZgRs.218654$pV4.191473@newsfe21.iad> |
| In reply to | #22217 |
On 02/08/2013 08:18 PM, Arne Vajhøj wrote: > On 2/8/2013 7:13 PM, Lew wrote: >> Arne Vajhøj wrote: >>>> And annotations are put on types not on instances. >> >> http://docs.oracle.com/javase/7/docs/api/java/lang/annotation/ElementType.html >> >> contradicts you. >> >> How else would injection work? > > ???? > > X a; > X b; > > what annotation are you suggesting that I use two distinguish between > the two X'es? > > Arne > This suddenly got confusing. I believe we all know that we can have one set of annotations on X a; and a completely different set of annotations on X b; Clearly the annotations must be appropriate for type 'X', but they are separately associated to 'a' and to 'b'. AHS
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-02-08 19:52 -0500 |
| Message-ID | <51159db8$0$288$14726298@news.sunsite.dk> |
| In reply to | #22220 |
On 2/8/2013 7:44 PM, Arved Sandstrom wrote:
> On 02/08/2013 08:18 PM, Arne Vajhøj wrote:
>> On 2/8/2013 7:13 PM, Lew wrote:
>>> Arne Vajhøj wrote:
>>>>> And annotations are put on types not on instances.
>>>
>>> http://docs.oracle.com/javase/7/docs/api/java/lang/annotation/ElementType.html
>>>
>>>
>>> contradicts you.
>>>
>>> How else would injection work?
>>
>> ????
>>
>> X a;
>> X b;
>>
>> what annotation are you suggesting that I use two distinguish between
>> the two X'es?
>>
> This suddenly got confusing. I believe we all know that we can have one
> set of annotations on
>
> X a;
>
> and a completely different set of annotations on
>
> X b;
>
> Clearly the annotations must be appropriate for type 'X', but they are
> separately associated to 'a' and to 'b'.
Maybe I am the only one in the known universe that don't know.
But let us say we have:
X a = new X(aa);
X b = new X(bb);
test(a,b);
void test(X a,X b) {
}
How should the annotation look like, how should it be put on and
how do I get it in test?
I know how to put an annotation on the type X that I can get in
test. But that is the same for both a and b. Roedy needs a
different annotation (value).
I don't think I have ever seen that done with instances.
Arne
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2013-02-08 17:06 -0800 |
| Message-ID | <de60670c-5ed6-4bae-a79a-dea67e075129@googlegroups.com> |
| In reply to | #22223 |
Arne Vajhøj wrote:
> Maybe I am the only one in the known universe that don't know.
>
> But let us say we have:
>
> X a = new X(aa);
> X b = new X(bb);
>
> test(a,b);
>
> void test(X a,X b) {
>
> }
>
> How should the annotation look like, how should it be put on and
> how do I get it in test?
I don't understand your question "How do I get it in test?"
> I know how to put an annotation on the type X that I can get in
> test. But that is the same for both a and b. Roedy needs a
> different annotation (value).
>
> I don't think I have ever seen that done with instances.
Take a look at JPA:
@Column(name="SURNAME")
private String lastName;
@Column(name="GIVENNAME")
private String firstName;
Is that not annotating a field? And annotations can annotate a local variable, too.
It's not annotating 'String'.
Is that not what you wanted?
--
Lew
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2013-02-08 17:08 -0800 |
| Message-ID | <cfd6fa62-08c1-450e-b1d8-783c8e7bfa46@googlegroups.com> |
| In reply to | #22226 |
Lew wrote:
> Arne Vajhøj wrote:
>> Maybe I am the only one in the known universe that don't know.
>
>> But let us say we have:
>
>> X a = new X(aa);
>> X b = new X(bb);
>
>> test(a,b);
>
>> void test(X a,X b) {
>> }
>>
>> How should the annotation look like, how should it be put on and
>> how do I get it in test?
>
> I don't understand your question "How do I get it in test?"
>
>> I know how to put an annotation on the type X that I can get in
>> test. But that is the same for both a and b. Roedy needs a
>> different annotation (value).
>
>> I don't think I have ever seen that done with instances.
>
> Take a look at JPA:
>
> @Column(name="SURNAME")
> private String lastName;
>
> @Column(name="GIVENNAME")
> private String firstName;
>
> Is that not annotating a field? And annotations can annotate a local variable, too.
>
> It's not annotating 'String'.
>
> Is that not what you wanted?
public void test( @Nullable Foo x, @NotNull Bar y)
{ ... }
--
Lew
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-02-08 20:09 -0500 |
| Message-ID | <5115a1bb$0$288$14726298@news.sunsite.dk> |
| In reply to | #22226 |
On 2/8/2013 8:06 PM, Lew wrote:
> Arne Vajhøj wrote:
>> Maybe I am the only one in the known universe that don't know.
>>
>> But let us say we have:
>>
>> X a = new X(aa);
>> X b = new X(bb);
>>
>> test(a,b);
>>
>> void test(X a,X b) {
>>
>> }
>>
>> How should the annotation look like, how should it be put on and
>> how do I get it in test?
>
> I don't understand your question "How do I get it in test?"
How do I inside the test method retrieve the different
annotations on a an b?
>> I know how to put an annotation on the type X that I can get in
>> test. But that is the same for both a and b. Roedy needs a
>> different annotation (value).
>>
>> I don't think I have ever seen that done with instances.
>
> Take a look at JPA:
>
> @Column(name="SURNAME")
> private String lastName;
>
> @Column(name="GIVENNAME")
> private String firstName;
>
> Is that not annotating a field? And annotations can annotate a local variable, too.
>
> It's not annotating 'String'.
>
> Is that not what you wanted?
Not unless one can call a method with firstName and lastName and
inside that method retrieve the two column names.
Arne
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2013-02-08 17:16 -0800 |
| Message-ID | <c0d2e3c5-2af1-47a5-bbc0-64b1bf1d6d13@googlegroups.com> |
| In reply to | #22229 |
Arne Vajhøj wrote:
> Lew wrote:
>> Arne Vajh�j wrote:
>>> Maybe I am the only one in the known universe that don't know.
>
>>> But let us say we have:
>
>>> X a = new X(aa);
>>> X b = new X(bb);
>>> test(a,b);
>>> void test(X a,X b) {
>>> }
>>> How should the annotation look like, how should it be put on and
>>> how do I get it in test?
>
>> I don't understand your question "How do I get it in test?"
>
> How do I inside the test method retrieve the different
> annotations on a an b?
>>> I know how to put an annotation on the type X that I can get in
>>> test. But that is the same for both a and b. Roedy needs a
>>> different annotation (value).
>>>
>>> I don't think I have ever seen that done with instances.
>
>> Take a look at JPA:
>
>> @Column(name="SURNAME")
>> private String lastName;
>>
>> @Column(name="GIVENNAME")
>> private String firstName;
>>
>> Is that not annotating a field? And annotations can annotate a local variable, too.
>>
>> It's not annotating 'String'.
>>
>> Is that not what you wanted?
>
> Not unless one can call a method with firstName and lastName and
> inside that method retrieve the two column names.
You retrieve annotations via reflection, but that is neither relevant to what I was answering
nor something you normally want to do.
I was answering your assertions that annotations only apply to a type. That's just wrong.
Clearly you can annotate fields, local variables, constructors, methods, ...
Annotations are METAprogramming. They're handled outside the code that is annotated. By other code.
You don't retrieve the annotations inside the method. You get other behavior, like automagically
having a connection to the correct table element. SO THAT YOU DON'T HAVE TO RETRIEVE IT.
That's the whole point of having the annotation. If you want to retrieve the value, don't use annotations.
Or with @NonNull you might get compiler-time explosion over a possibility that the variable could be
null, or a runtime error if it is without having to explicitly code for it. Again, the point is you do the
annotation so the code inside the method doesn't have to deal with it.
Use annotations correctly and your question vanishes. Your assertion that annotations only apply to
types is already wrong.
--
Lew
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-02-08 20:36 -0500 |
| Message-ID | <5115a832$0$291$14726298@news.sunsite.dk> |
| In reply to | #22231 |
On 2/8/2013 8:16 PM, Lew wrote:
> Arne Vajhøj wrote:
>> Lew wrote:
>>> Arne Vajh�j wrote:
>>>> Maybe I am the only one in the known universe that don't know.
>>
>>>> But let us say we have:
>>
>>>> X a = new X(aa);
>>>> X b = new X(bb);
>>>> test(a,b);
>>>> void test(X a,X b) {
>>>> }
>>>> How should the annotation look like, how should it be put on and
>>>> how do I get it in test?
>>
>>> I don't understand your question "How do I get it in test?"
>>
>> How do I inside the test method retrieve the different
>> annotations on a an b?
>
>>>> I know how to put an annotation on the type X that I can get in
>>>> test. But that is the same for both a and b. Roedy needs a
>>>> different annotation (value).
>>>>
>>>> I don't think I have ever seen that done with instances.
>>
>>> Take a look at JPA:
>>
>>> @Column(name="SURNAME")
>>> private String lastName;
>>>
>>> @Column(name="GIVENNAME")
>>> private String firstName;
>>>
>>> Is that not annotating a field? And annotations can annotate a local variable, too.
>>>
>>> It's not annotating 'String'.
>>>
>>> Is that not what you wanted?
>>
>> Not unless one can call a method with firstName and lastName and
>> inside that method retrieve the two column names.
>
> You retrieve annotations via reflection
In this case?
> , but that is neither relevant to what I was answering
> nor something you normally want to do.
>
> I was answering your assertions that annotations only apply to a type. That's just wrong.
> Clearly you can annotate fields, local variables, constructors, methods, ...
>
> Annotations are METAprogramming. They're handled outside the code that is annotated. By other code.
>
> You don't retrieve the annotations inside the method. You get other behavior, like automagically
> having a connection to the correct table element. SO THAT YOU DON'T HAVE TO RETRIEVE IT.
> That's the whole point of having the annotation. If you want to retrieve the value, don't use annotations.
>
> Or with @NonNull you might get compiler-time explosion over a possibility that the variable could be
> null, or a runtime error if it is without having to explicitly code for it. Again, the point is you do the
> annotation so the code inside the method doesn't have to deal with it.
>
> Use annotations correctly and your question vanishes. Your assertion that annotations only apply to
> types is already wrong.
Maybe you should read the context.
I answered a question whether annotations could solve a specific problem.
For annotations to solve that problem they would need to be applied
to instances similar to how it can be done for types.
All the stuff you list are utterly irrelevant for the question asked.
Arne
[toc] | [prev] | [next] | [standalone]
| From | Arved Sandstrom <asandstrom2@eastlink.ca> |
|---|---|
| Date | 2013-02-09 08:14 -0400 |
| Message-ID | <g4rRs.121726$EO2.63099@newsfe04.iad> |
| In reply to | #22235 |
On 02/08/2013 09:36 PM, Arne Vajhøj wrote: [ SNIP ] > > Maybe you should read the context. > > I answered a question whether annotations could solve a specific problem. > > For annotations to solve that problem they would need to be applied > to instances similar to how it can be done for types. > > All the stuff you list are utterly irrelevant for the question asked. > > Arne > I think the best bet here is to wait for JDK 8. JEP 118, which appears to still be in play, is for exactly this. I just now tried this out with the latest build, and it looks like they are working on it. You can get a list of parameters on a Method, as instances of class java.lang.reflect.Parameter, and there is a method getName() in the Parameter class. Unfortunately right now it still prints out values like 'arg0' and 'arg1', regardless of the actual names, but the idea is there. AHS
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2013-02-08 16:10 -0800 |
| Message-ID | <6b74802c-6043-46c1-a27e-23411aa84d95@googlegroups.com> |
| In reply to | #22211 |
Roedy Green wrote: > In the olden days PL/I has a output mechanism called PUT DATA > > Expresses Javesquely it would look like this: > > out.putd ( xlow, xhigh); > > It would output > > xlow=23.4 xhigh=200.0 > > (There was also a keyword/value input method. It was mainly helpful > in debugging.) > > I could see how you could implement it in a preprocessor or > amanuensis, but can you do it with a pure Java method? What do you mean by "amanuensis"? -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2013-02-09 09:54 -0800 |
| Message-ID | <vu1dh8tigra6jkl6e0gff72tlll9nh4pcr@4ax.com> |
| In reply to | #22214 |
On Fri, 8 Feb 2013 16:10:48 -0800 (PST), Lew <lewbloch@gmail.com> wrote, quoted or indirectly quoted someone who said : > >What do you mean by "amanuensis"? see http://mindprod.com/jgloss/amanuensis.html -- Roedy Green Canadian Mind Products http://mindprod.com The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time. ~ Tom Cargill Ninety-ninety Law
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2013-02-09 15:49 -0800 |
| Message-ID | <q0odh8h2o01gg0ehdc7krtebd7o84acu05@4ax.com> |
| In reply to | #22211 |
On Fri, 08 Feb 2013 14:21:50 -0800, Roedy Green <see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted someone who said : >In the olden days PL/I has a output mechanism called PUT DATA I have written this up as a beginner student project at http://mindprod/project/putdata.html -- Roedy Green Canadian Mind Products http://mindprod.com The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time. ~ Tom Cargill Ninety-ninety Law
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2013-02-09 19:21 -0500 |
| Message-ID | <5116e823$0$285$14726298@news.sunsite.dk> |
| In reply to | #22256 |
On 2/9/2013 6:49 PM, Roedy Green wrote:
> On Fri, 08 Feb 2013 14:21:50 -0800, Roedy Green
> <see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
> someone who said :
>> In the olden days PL/I has a output mechanism called PUT DATA
>
> I have written this up as a beginner student project at
>
> http://mindprod/project/putdata.html
Today the feature is probably more common seen in C/C++.
With something like:
#define PRINTD(x) printf("%s=%d\n", #x, x)
#define PRINTS(x) printf("%s=%s\n", #x, x)
Arne
PS: I know that I can do:
#define PRINTD(x) printf(#x "=%d\n", x)
#define PRINTS(x) printf(#x "=%s\n", x)
but it just doesn't seem as readable to me.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web