RE: two-tier proposals

"Mark Hahn" <[email protected]>
Newsgroups gmane.comp.lang.prothon.user,gmane.spam.detected
Message-ID <000401c45946$63109370$0b01a8c0@mark>
From: Paul Prescod

> > I also made a small proposal in passing that is less than a class 
> > where each method in a prototype is flagged to indicate whether the 
> > method should respond to calls from only instances 
> (extensions) of the 
> > prototype, the prototype itself, or both.  This would allow methods 
> > like str_ and call_ to behave differently for the prototype and the 
> > instances, giving much of the behavior that classes have in Python.
> 
> This proposal deserves more thought...

I am leaning more towards Serge's thinking myself at the moment, which
is only slightly different.  I posted a new set of guidelines in a new
thread.  It includes sort of a proposal.

> does it mean that 
> prototypes would 
> have two different attribute dictionaries? One for 
> prototype-as-prototype and another for instances?

In my newer idea the different namespaces would be in different objects.
The instance attributes would be in the main Class object.  The class
attributes would be in a special attribute of the class object.  Maybe
it would be Class.class_.  Factory would be in Class.factory_, etc.

> Which namespace owns the init_ method?

The instance section (Class object) since init_ is called on the
instance after it is created.

> How do I introspect the two versions of the (e.g.) str_ function for 
> instance to overwrite them or something?

That is a problem with my minimal idea.  My newer idea would have them
in the different objects in different Class attributes.

> Another way to handle this is:
> 
> #!/usr/local/bin/prothon
> 
> object a:
> ~  def str_():
> ~     #print Object.str_{self}()
> ~     if self is a:
> ~        return "<prototype A>"
> ~     else:
> ~        return  "<instance of A>"
> 
> print a
> print a()

Yes.  That is the kludge I referred to earlier to make prototypes print
out differently.

> The interesting bit is that Prothon makes it easy for you to 
> control how 
> the prototype/class stringifies and Python makes it hard. But 
> then how 
> often do you care how the prototype/class stringifies? As long as the 
> default is reasonable, you usually don't care.

Well, you and Christian both bitched about it :-)  I assume the Prothon
list would see many more bitches over the years to come.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.