PUT DATA

Discussion in 'Java' started by Roedy Green, Feb 8, 2013.

  1. Roedy Green

    Roedy Green Guest

    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
     
    Roedy Green, Feb 8, 2013
    #1
    1. Advertising

  2. Roedy Green

    Arne Vajhøj Guest

    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
     
    Arne Vajhøj, Feb 8, 2013
    #2
    1. Advertising

  3. Roedy Green

    Lew Guest

    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
     
    Lew, Feb 9, 2013
    #3
  4. Roedy Green

    Lew Guest

    Lew, Feb 9, 2013
    #4
  5. Roedy Green

    Arne Vajhøj Guest

    Arne Vajhøj, Feb 9, 2013
    #5
  6. 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
     
    Arved Sandstrom, Feb 9, 2013
    #6
  7. Roedy Green

    Arne Vajhøj Guest

    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
     
    Arne Vajhøj, Feb 9, 2013
    #7
  8. Roedy Green

    Lew Guest

    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
     
    Lew, Feb 9, 2013
    #8
  9. Roedy Green

    Lew Guest

    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
     
    Lew, Feb 9, 2013
    #9
  10. Roedy Green

    Arne Vajhøj Guest

    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
     
    Arne Vajhøj, Feb 9, 2013
    #10
  11. Roedy Green

    Lew Guest

    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 TORETRIEVE 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
     
    Lew, Feb 9, 2013
    #11
  12. Roedy Green

    Arne Vajhøj Guest

    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
     
    Arne Vajhøj, Feb 9, 2013
    #12
  13. 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
     
    Arved Sandstrom, Feb 9, 2013
    #13
  14. Roedy Green

    Roedy Green Guest

    On Fri, 8 Feb 2013 16:10:48 -0800 (PST), Lew <>
    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
     
    Roedy Green, Feb 9, 2013
    #14
  15. Roedy Green

    Roedy Green Guest

    On Fri, 08 Feb 2013 14:21:50 -0800, Roedy Green
    <> 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
     
    Roedy Green, Feb 9, 2013
    #15
  16. Roedy Green

    Arne Vajhøj Guest

    On 2/9/2013 6:49 PM, Roedy Green wrote:
    > On Fri, 08 Feb 2013 14:21:50 -0800, Roedy Green
    > <> 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.
     
    Arne Vajhøj, Feb 10, 2013
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sara T.

    Put data to DataGrid in memory

    Sara T., Jul 23, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    356
    Sara T.
    Jul 23, 2003
  2. ruca

    Put Data in DropDownList

    ruca, Feb 6, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    1,399
    Jim Hughes
    Feb 7, 2004
  3. Gill Smith

    How to put gif file in Data grid......

    Gill Smith, May 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    400
    Joe Fallon
    May 29, 2004
  4. =?Utf-8?B?Q2hyaXM=?=

    where to put load of static data?

    =?Utf-8?B?Q2hyaXM=?=, Oct 3, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    515
    =?Utf-8?B?Q2hyaXM=?=
    Oct 3, 2005
  5. Gabriel Rossetti
    Replies:
    3
    Views:
    576
    Jerry Hill
    Apr 25, 2008
Loading...

Share This Page