Re: Re: New stackless proposal
"Mark Hahn" <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <001501c467ae$87938920$0d01a8c0@MarkVaio> |
Paul Prescod wrote:
> Mark Hahn wrote:
>
>> ...
>>> 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.
>
> I see nothing in the example to indicate that OSThread inherits from
> thread1 or vice versa.
The statement "thread1 = OSThread(thread1)" is an instantiation. OSThread
is a prototype. thread1 is a func. OSThread extends Func and thread1 wraps
thread1. So I guess it both extends and wraps. I thought this was a common
"decorator" technique. I got it from Serge.
>> ... It just happens to reuse the thread1 binding.
>
> Can you see how that makes it more difficult to read the code?
This is just sample code. Would this code make you feel better:
def func(time):
first: thread1 = OSThread(thread1) # decorator
blah blah blah
>>> 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
>
> I think using call_ for this is confusing. If you really feel like you
> have to use call_ it would be a lot more clear to use it for starting.
> But perhaps better not to use it at all.
>
> thread1.setParams(10)
> thread1.start()
>
> Explicit is better than implicit!
I will revisit this.