Searching for a notion

S

Stefan Ram

»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.)
 
B

Bo Vance

Stefan said:
»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.
 
O

Owen Jacobson

  »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.
 
T

Tom Anderson

»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:
['__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']['__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']['__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:
<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:
['__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
 
J

Joshua Cranmer

Stefan said:
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.
 
B

Bo Vance

Stefan said:
»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?
 
B

Bo Vance

Bo said:
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
 
P

Patricia Shanahan

Stefan said:
»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
 
B

Bo Vance

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?
 
S

Stefan Ram

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top