Two Tier, call_ str_ fix

Mukhsein Johari <[email protected]>
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
I've been rereading the emails and I've been rereading
the proposal wiki. I have to say, I don't understand
what problem this is trying to solve. OK, please don't
flame me if I'm just being stupid. From my
understanding...

prothon cannot decide what to do when:

object MyObj:
  def str_():
    return("I'm a MyObj")

o = MyObj()  # this hangs prothon btw (latest release)

print(MyObj)     # correct syntax now? or print MyObj?
print(o)

I'm not sure what the problem is here :-(

Anyway onward to call_? Is it this problem:

object MyObj:
  def call_():
    return("I'm a MyObj")

ob = MyObj()

MyObj()
ob()

Maybe what we need is simply a change of syntax?

Instead of this:
ob = MyObj()

To specify that ob is an object that inherits MyObj's
attributes, why not:

ob = MyObj.inherit()

which is different from but consistent with:

ob = MyObj.copy()

Maybe we don't even need the keyword object? ("object"
is starting to feel like "class" to me)

If you want to define new behavior why not:

myPrototype = Object.inherit()

with myPrototype:
  x = 0
  y = 12
  def myfunc():
    return(self.x + self.y)

my2ndPrototype = myPrototype.inherit()

with my2ndPrototype:
  def myfunc():
    return(self.x * self.y)

If you then do:

with myPrototype:
  x = 42

Then:

O>> my2ndPrototype.x
42

This way if you define call_ you can do

myPrototype()

without any problems. If P2 inherits P1 and you want
to initialize you can always call init_ to
reinitialize P2. After all, prothon is protoype-based,
right? Which means we don't use blueprint-like
constructs like class. We add changes to the objects
directly. Of course, I could be missing the whole
point here...

________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html
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.