Searching for a notion

Discussion in 'Java' started by Stefan Ram, Sep 2, 2008.

  1. Stefan Ram

    Stefan Ram Guest

    »out« is a field of the class »java.lang.System«,
    »println« is a method of the object »java.lang.System.out«.

    Both classes and objects each can have fields and methods.
    Fields and methods of a class are called »static«,
    fields and methods of an object are called »non-static« (or so).

    Is there a supernotion for both classes and objects that
    means something like

    »an entity that can have fields and methods«,

    so that classes and objects are subnotions of this supernotion?

    ??
    /\
    ^ / \ ^
    is-a/ \is-a
    / \
    / \
    class object

    (In a sense a class is an object, but is more like a singleton
    with static lifetime. However, a class is not an object in the
    strict JLS sense of the word object, so I can't use »object«
    for this notion.)
     
    Stefan Ram, Sep 2, 2008
    #1
    1. Advertising

  2. Stefan Ram

    Bo Vance Guest

    Stefan Ram wrote:
    > »out« is a field of the class »java.lang.System«,
    > »println« is a method of the object »java.lang.System.out«.
    >
    > Both classes and objects each can have fields and methods.
    > Fields and methods of a class are called »static«,
    > fields and methods of an object are called »non-static« (or so).
    >
    > Is there a supernotion for both classes and objects that
    > means something like


    In the Java language? No. But you knew that.
    <http://lucacardelli.name/TheoryOfObjects.html>
    See the _Related Work_ link.

    >
    > »an entity that can have fields and methods«,
    >
    > so that classes and objects are subnotions of this supernotion?
    >
    > ??
    > /\
    > ^ / \ ^
    > is-a/ \is-a
    > / \
    > / \
    > class object
    >
    > (In a sense a class is an object, but is more like a singleton
    > with static lifetime. However, a class is not an object in the
    > strict JLS sense of the word object, so I can't use »object«
    > for this notion.)
    >
     
    Bo Vance, Sep 2, 2008
    #2
    1. Advertising

  3. Stefan Ram

    Bo Vance Guest

    Bo Vance wrote:
    > Stefan Ram wrote:
    >> »out« is a field of the class »java.lang.System«,
    >> »println« is a method of the object »java.lang.System.out«.
    >>
    >> Both classes and objects each can have fields and methods.
    >> Fields and methods of a class are called »static«,
    >> fields and methods of an object are called »non-static« (or so).
    >>
    >> Is there a supernotion for both classes and objects that
    >> means something like

    >
    > In the Java language? No. But you knew that.
    > <http://lucacardelli.name/TheoryOfObjects.html>
    > See the _Related Work_ link.


    On second thought..

    >
    >>
    >> »an entity that can have fields and methods«,
    >>
    >> so that classes and objects are subnotions of this supernotion?



    this
    >>
    >> ??
    >> /\
    >> ^ / \ ^
    >> is-a/ \is-a
    >> / \
    >> / \
    >> class object
    >>
    >> (In a sense a class is an object, but is more like a singleton
    >> with static lifetime. However, a class is not an object in the
    >> strict JLS sense of the word object, so I can't use »object«
    >> for this notion.)
    >>
     
    Bo Vance, Sep 2, 2008
    #3
  4. Stefan Ram

    Bo Vance Guest

    Bo Vance wrote:
    > Bo Vance wrote:
    >> Stefan Ram wrote:
    >>> »out« is a field of the class »java.lang.System«,
    >>> »println« is a method of the object »java.lang.System.out«.
    >>>
    >>> Both classes and objects each can have fields and methods.
    >>> Fields and methods of a class are called »static«,
    >>> fields and methods of an object are called »non-static« (or so).
    >>>
    >>> Is there a supernotion for both classes and objects that
    >>> means something like

    >>
    >> In the Java language? No. But you knew that.
    >> <http://lucacardelli.name/TheoryOfObjects.html>
    >> See the _Related Work_ link.

    >
    > On second thought..
    >
    >>
    >>>
    >>> »an entity that can have fields and methods«,
    >>>
    >>> so that classes and objects are subnotions of this supernotion?

    >
    >
    > this
    >>>
    >>> ??
    >>> /\
    >>> ^ / \ ^
    >>> is-a/ \is-a
    >>> / \
    >>> / \
    >>> class object
    >>>
    >>> (In a sense a class is an object, but is more like a singleton
    >>> with static lifetime. However, a class is not an object in the
    >>> strict JLS sense of the word object, so I can't use »object«
    >>> for this notion.)
    >>>


    <http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6479372>
     
    Bo Vance, Sep 2, 2008
    #4
  5. On Sep 1, 9:56 pm, -berlin.de (Stefan Ram) wrote:
    >   »out« is a field of the class »java.lang.System«,
    >   »println« is a method of the object »java.lang.System.out«.
    >
    >   Both classes and objects each can have fields and methods.
    >   Fields and methods of a class are called »static«,
    >   fields and methods of an object are called »non-static« (or so).
    >
    >   Is there a supernotion for both classes and objects that
    >   means something like
    >
    >       »an entity that can have fields and methods«,
    >
    >   so that classes and objects are subnotions of this supernotion?
    >
    >                       ??
    >                       /\
    >                   ^  /  \   ^
    >                 is-a/    \is-a
    >                    /      \
    >                   /        \
    >                class     object
    >
    >   (In a sense a class is an object, but is more like a singleton
    >   with static lifetime. However, a class is not an object in the
    >   strict JLS sense of the word object, so I can't use »object«
    >   for this notion.)


    The notion of a "metaclass" is useful here. A metaclass is a class
    whose instances are classes. In Java, the closest thing to a
    metaclass is 'Class' itself, as Object.class.class is Class<Class>.
    Systems like Python and Smalltalk have more fully-featured metaclasses
    and even allow programmers to define their own.

    The definitions of "root" metaclasses -- the ones included in a
    language -- tend to either be axiomatic ("it is this way by
    definition") or circular.
     
    Owen Jacobson, Sep 2, 2008
    #5
  6. Stefan Ram

    Bo Vance Guest

    Bo Vance wrote:
    > Stefan Ram wrote:
    >> »out« is a field of the class »java.lang.System«,
    >> »println« is a method of the object »java.lang.System.out«.
    >>
    >> Both classes and objects each can have fields and methods.
    >> Fields and methods of a class are called »static«,
    >> fields and methods of an object are called »non-static« (or so).
    >>
    >> Is there a supernotion for both classes and objects that
    >> means something like

    >
    > In the Java language? No. But you knew that.
    > <http://lucacardelli.name/TheoryOfObjects.html>
    > See the _Related Work_ link.
    >
    >>
    >> »an entity that can have fields and methods«,
    >>
    >> so that classes and objects are subnotions of this supernotion?


    YAFT
    Speaking strictly for myself.


    Here lie Dragons
    or
    Can O'Worms
    >> ??
    >> /\
    >> ^ / \ ^
    >> is-a/ \is-a
    >> / \
    >> / \
    >> class object
    >>


    <http://www.ksc.com/article3.htm>


    >> (In a sense a class is an object, but is more like a singleton
    >> with static lifetime. However, a class is not an object in the
    >> strict JLS sense of the word object, so I can't use »object«
    >> for this notion.)
    >>
     
    Bo Vance, Sep 2, 2008
    #6
  7. Stefan Ram

    zerg Guest

    Bo Vance wrote:
    > YAFT
    > Speaking strictly for myself.
    >
    >
    > Here lie Dragons
    > or
    > Can O'Worms
    >>> ??
    >>> /\
    >>> ^ / \ ^
    >>> is-a/ \is-a
    >>> / \
    >>> / \
    >>> class object
    >>>


    Cute. But what's "YAFT"?
     
    zerg, Sep 2, 2008
    #7
  8. Stefan Ram

    Bo Vance Guest

    zerg wrote:
    > Bo Vance wrote:
    >> YAFT
    >> Speaking strictly for myself.
    >>
    >>
    >> Here lie Dragons
    >> or
    >> Can O'Worms
    >>>> ??
    >>>> /\
    >>>> ^ / \ ^
    >>>> is-a/ \is-a
    >>>> / \
    >>>> / \
    >>>> class object
    >>>>

    >
    > Cute. But what's "YAFT"?

    _Y_et _A_nother _F_leeting _T_hought
     
    Bo Vance, Sep 2, 2008
    #8
  9. Stefan Ram

    Tom Anderson Guest

    On Tue, 2 Sep 2008, Stefan Ram wrote:

    > »out« is a field of the class »java.lang.System«,
    > »println« is a method of the object »java.lang.System.out«.
    >
    > Both classes and objects each can have fields and methods.
    > Fields and methods of a class are called »static«,
    > fields and methods of an object are called »non-static« (or so).
    >
    > Is there a supernotion for both classes and objects that
    > means something like
    >
    > »an entity that can have fields and methods«,
    >
    > so that classes and objects are subnotions of this supernotion?


    In python, such things are called namespaces. Modules, classes and objects
    are all namespaces. But then, modules and classes are both objects (as are
    methods), so that kind of goes without saying. Indeed, people usually just
    use 'object' to mean a namespace, which is more a of a vague handwavey
    term.

    To illustrate this, python's analogue of System.out.print, explored with
    the built-in dir() function, which returns a list of the names defined in
    a namespace:

    >>> import sys
    >>> dir(sys)

    ['__displayhook__', '__doc__', '__excepthook__', '__name__', '__stderr__',
    '__stdin__', '__stdout__', '_current_frames', '_getframe', 'api_version',
    'argv', 'builtin_module_names', 'byteorder', 'call_tracing', 'callstats',
    'copyright', 'displayhook', 'exc_clear', 'exc_info', 'exc_type',
    'excepthook', 'exec_prefix', 'executable', 'exit', 'getcheckinterval',
    'getdefaultencoding', 'getdlopenflags', 'getfilesystemencoding',
    'getrecursionlimit', 'getrefcount', 'hexversion', 'last_traceback',
    'last_type', 'last_value', 'maxint', 'maxunicode', 'meta_path', 'modules',
    'path', 'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'ps1',
    'ps2', 'setcheckinterval', 'setdlopenflags', 'setprofile',
    'setrecursionlimit', 'settrace', 'stderr', 'stdin', 'stdout',
    'subversion', 'version', 'version_info', 'warnoptions']
    >>> dir(sys.stdout)

    ['__class__', '__delattr__', '__doc__', '__enter__', '__exit__',
    '__getattribute__', '__hash__', '__init__', '__iter__', '__new__',
    '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
    'close', 'closed', 'encoding', 'fileno', 'flush', 'isatty', 'mode',
    'name', 'newlines', 'next', 'read', 'readinto', 'readline', 'readlines',
    'seek', 'softspace', 'tell', 'truncate', 'write', 'writelines',
    'xreadlines']
    >>> dir(sys.stdout.write)

    ['__call__', '__class__', '__cmp__', '__delattr__', '__doc__',
    '__getattribute__', '__hash__', '__init__', '__module__', '__name__',
    '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__self__',
    '__setattr__', '__str__']

    Because modules are objects, you can do things like this:

    >>> foo = sys
    >>> foo.stdout

    <open file '<stdout>', mode 'w' at 0x12068>

    That's not a huge amount of use, but hey. I think it's exploited to load
    the platform-specific version of the os library, though - the VM loads,
    say, 'macos', then assigns it to the name 'os'.

    Local variables also constitute a namespace:

    >>> somevar = 23
    >>> dir()

    ['__builtins__', '__doc__', '__name__', 'foo', 'somevar', 'sys']

    There's generally way to get hold of a namespace as a dictionary object
    too, but that's another story.

    tom

    --
    Passersby were amazed by the unusually large amounts of blood.
     
    Tom Anderson, Sep 3, 2008
    #9
  10. Stefan Ram wrote:
    > Is there a supernotion for both classes and objects that
    > means something like
    >
    > »an entity that can have fields and methods«,


    I've been playing around with this myself, as I am trying to create some
    type hierarchies that work with C++, Python, and Java. My WIP is `type'
    (I'm not happy with this), and Tom's suggestion of `namespace' doesn't
    feel quite right. `Container' and `scope' sound better to me, but the
    first one feels too generic while I am probably overloading the latter a
    bit too much.

    I recall seeing `type' related to classes and objects in some python
    documentation once, but don't push me too heavily on that being correct.
    --
    Beware of bugs in the above code; I have only proved it correct, not
    tried it. -- Donald E. Knuth
     
    Joshua Cranmer, Sep 3, 2008
    #10
  11. Stefan Ram

    Bo Vance Guest

    Stefan Ram wrote:
    > »out« is a field of the class »java.lang.System«,
    > »println« is a method of the object »java.lang.System.out«.
    >
    > Both classes and objects each can have fields and methods.
    > Fields and methods of a class are called »static«,
    > fields and methods of an object are called »non-static« (or so).
    >
    > Is there a supernotion for both classes and objects that
    > means something like
    >
    > »an entity that can have fields and methods«,
    >
    > so that classes and objects are subnotions of this supernotion?
    >
    > ??
    > /\
    > ^ / \ ^
    > is-a/ \is-a
    > / \
    > / \
    > class object
    >
    > (In a sense a class is an object, but is more like a singleton
    > with static lifetime. However, a class is not an object in the
    > strict JLS sense of the word object, so I can't use »object«
    > for this notion.)
    >


    If class is a ?? and object is a ??,
    what is their commonality and difference?
     
    Bo Vance, Sep 3, 2008
    #11
  12. Stefan Ram

    Bo Vance Guest

    Bo Vance wrote:
    > Stefan Ram wrote:
    >> »out« is a field of the class »java.lang.System«,
    >> »println« is a method of the object »java.lang.System.out«.
    >>
    >> Both classes and objects each can have fields and methods.
    >> Fields and methods of a class are called »static«,
    >> fields and methods of an object are called »non-static« (or so).
    >>
    >> Is there a supernotion for both classes and objects that
    >> means something like
    >> »an entity that can have fields and methods«,
    >>
    >> so that classes and objects are subnotions of this supernotion?
    >>
    >> ??
    >> /\
    >> ^ / \ ^
    >> is-a/ \is-a
    >> / \
    >> / \
    >> class object
    >>
    >> (In a sense a class is an object, but is more like a singleton
    >> with static lifetime. However, a class is not an object in the
    >> strict JLS sense of the word object, so I can't use »object«
    >> for this notion.)
    >>

    >
    > If class is a ?? and object is a ??,
    > what is their commonality and difference?
    >
    >


    >> Both classes and objects each can have fields and methods.
    >> Fields and methods of a class are called »static«,
    >> fields and methods of an object are called »non-static« (or so).


    Maybe I don't understand what you are after here.
     
    Bo Vance, Sep 3, 2008
    #12
  13. Stefan Ram

    Bo Vance Guest

    Bo Vance wrote:
    > Bo Vance wrote:
    >> Stefan Ram wrote:
    >>> »out« is a field of the class »java.lang.System«,
    >>> »println« is a method of the object »java.lang.System.out«.
    >>>
    >>> Both classes and objects each can have fields and methods.
    >>> Fields and methods of a class are called »static«,
    >>> fields and methods of an object are called »non-static« (or so).
    >>>
    >>> Is there a supernotion for both classes and objects that
    >>> means something like
    >>> »an entity that can have fields and methods«,
    >>>
    >>> so that classes and objects are subnotions of this supernotion?
    >>>
    >>> ??
    >>> /\
    >>> ^ / \ ^
    >>> is-a/ \is-a
    >>> / \
    >>> / \
    >>> class object
    >>>
    >>> (In a sense a class is an object, but is more like a singleton
    >>> with static lifetime. However, a class is not an object in the
    >>> strict JLS sense of the word object, so I can't use »object«
    >>> for this notion.)
    >>>

    >>
    >> If class is a ?? and object is a ??,
    >> what is their commonality and difference?
    >>
    >>

    >
    > >> Both classes and objects each can have fields and methods.
    > >> Fields and methods of a class are called »static«,
    > >> fields and methods of an object are called »non-static« (or so).

    >
    > Maybe I don't understand what you are after here.
    >
    >


    »out« is a field of the class »java.lang.System«,
    »println« is a method of the object »java.lang.System.out«.

    I would be inclined to say that println is a method of
    the class java.io.PrintStream
     
    Bo Vance, Sep 3, 2008
    #13
  14. Stefan Ram wrote:
    > »out« is a field of the class »java.lang.System«,
    > »println« is a method of the object »java.lang.System.out«.
    >
    > Both classes and objects each can have fields and methods.
    > Fields and methods of a class are called »static«,
    > fields and methods of an object are called »non-static« (or so).
    >
    > Is there a supernotion for both classes and objects that
    > means something like
    >
    > »an entity that can have fields and methods«,
    >
    > so that classes and objects are subnotions of this supernotion?
    >
    > ??
    > /\
    > ^ / \ ^
    > is-a/ \is-a
    > / \
    > / \
    > class object
    >
    > (In a sense a class is an object, but is more like a singleton
    > with static lifetime. However, a class is not an object in the
    > strict JLS sense of the word object, so I can't use »object«
    > for this notion.)
    >


    In this sort of context, I would use "Java object" for things that are
    specifically designated as objects in the JLS, and "object" for anything
    that has fields and methods:

    object
    /\
    ^ / \ ^
    is-a/ \is-a
    / \
    / \
    Java class Java object

    Patricia
     
    Patricia Shanahan, Sep 3, 2008
    #14
  15. Stefan Ram

    Bo Vance Guest

    Lew wrote:
    > Bo Vance wrote:
    >> »out« is a field of the class »java.lang.System«,
    >> »println« is a method of the object »java.lang.System.out«.
    >>
    >> I would be inclined to say that println is a method of
    >> the class java.io.PrintStream


    >
    > It's an instance method,

    Well, it's not a static method..
    > so it must be dispatched through an instance.

    Yep.
    > I that respect it is a method of the instance.

    In what respect is it not a method of the class?
    Or, how do I differentiate?

    Even the terminology
    > "instance method" is the syntactic synonym of "method of an instance".
    >

    Huh?

    > All methods are methods of a class, but Stefan's question and the
    > context of this thread are the distinctions between class (static) and
    > instance members, and what the common "thing" is that both class and
    > instance typify.


    I wasn't absolutely certain that Stefan's question and the context of
    this thread had been determined to be so, thus my statement upthread.
    Stefan declared a scenario in which a class (is a) "thing" and an object
    (is a) "thing" and I suppose this "relation" drew my attention away from
    this class/instance, static/non-static distinction you may have
    clarified here.

    My contention, now stated explicitly, is that there has been an enormous
    volume of work done by people much smarter than I attempting to rectify
    the (to me) non-congruent concepts of type/class, object/storage.
    I can't pass a value judgement upon these efforts. I think I stated
    this implicitly upthread in the links I posted. Maybe not.

    >
    > I say the common "thing" (and maybe we should just use the word "thing")
    > is an "object" in an overarching sense that subsumes the more
    > specialized sense as the JLS uses the word .


    I don't understand this sentence so I cannot say how this next follows?

    > This is reflected inside
    > Java by the representation of each class with a Class<?> object.
    >
     
    Bo Vance, Sep 3, 2008
    #15
  16. Stefan Ram

    Stefan Ram Guest

    -berlin.de (Stefan Ram) writes:
    >so that classes and objects are subnotions of this supernotion?


    Thanks for the answers!

    In the mean-time, I have also had another idea for the term
    wanted:

    For example, when one wants to test a class or an object,
    one writes a /test client/. So, what is the counterpart of
    a client? - It is a service!

    Thus, classes and objects both are services.

    The term service might be too general, because a package or
    jar also might be deemed a service in this sense; or it might
    be mismatched with »service« in the sense of »service-oriented
    architecture« (SOA) or »web service«, but in an appropriate
    context, it might be possible to use this.
     
    Stefan Ram, Sep 3, 2008
    #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. Derek Simmons
    Replies:
    1
    Views:
    562
    Derek Simmons
    Mar 31, 2005
  2. Rainer
    Replies:
    3
    Views:
    470
    Swapnajit Mittra
    Apr 26, 2005
  3. T Chheng

    class? :: notion

    T Chheng, Aug 17, 2004, in forum: Perl
    Replies:
    1
    Views:
    466
    Jim Gibson
    Aug 17, 2004
  4. Arien Malec

    PEP318: radical notion

    Arien Malec, Aug 23, 2004, in forum: Python
    Replies:
    14
    Views:
    530
    Arien Malec
    Aug 27, 2004
  5. stumblng.tumblr
    Replies:
    1
    Views:
    217
    stumblng.tumblr
    Feb 4, 2008
Loading...

Share This Page