Re: Re: New stackless proposal

"Mark Hahn" <[email protected]>
Newsgroups gmane.comp.lang.prothon.user
Message-ID <006f01c46798$75f1d750$0d01a8c0@MarkVaio>
Paul Prescod wrote:
> I don't have time today to really understand all of that stuff
> especially given that I don't use threads that much.
> 
> One thing jumped out at me as really weird and unPythonic (and
> probably unProthonic).
> 
>>> def thread1(seconds):           # (*12)
> ...    print 'thread1 is running'
> ...    Sleep(seconds * 1.0)
> ...    print 'thread1 is stopping'
> ...
>>> thread1 = OSThread(thread1)
> <OSThread:41fc3a2:uninitialized>
>>> thread1 = thread1(10)  # call thread1 to "arm" it(*1,5)
>>> thread1
> <OSThread:41fc3a2:armed>
>>> thread1.start()        # these two could have been
>>> thread1(10).start() thread1 is running thread1
> <OSThread:41fc3a2:running>
>>> 
> thread1 is stopping
> 
> The name thread1 is bound 3 times. As a coding style this is
> questionable. 
> 
> I notice you use a wrapping model here rather than an inheritance
> model (opposite of properties). OSThread looks like a wrapper.

It is an inheritance model.  It just happens to reuse the thread1 binding.

> I don't understand why you use call_ to arm a thread and then rebind
> the name. If the call_ function mutates the underlying object then
> why do 
> you have to rebind the name? 

That is a mistake.  I will change it to remove the assignment:

     thread1(10)  # call thread1 to "arm" it
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.