qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Stick to loops


From: Paolo Bonzini
Subject: Re: [Qemu-devel] Stick to loops
Date: Mon, 12 Oct 2015 12:24:29 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0


On 12/10/2015 12:00, Daniel P. Berrange wrote:
> I don't think your example here is a reasonable comparison when you consider
> the full extent of this patch series. You are only having to iterate over a
> single data structure here. At the end of this patch series we have to
> iterate over multiple data structures spread across the object instance
> and class hierarchy, so writing a 'next' like method is not as trivial
> as you suggest with this comparison.
> 
> > Higher-order functions are a wonderful tool if the language is equipped
> > for them.  In Lisp, for instance, you'd have everything in one place and
> > no need for the awkward marshalling and unmarshalling of arguments,
> > thanks to nested functions.
> > 
> > In C, stick to loops.  That's what the language supports.
> 
> You're really arguing against use of function callbacks in general with
> this comparison to LISP. I don't think that's really practical in the
> real world, as any integration with event loop needs callbacks, which
> share al the same limitations as callbacks used with this foreach()
> style iterator. Given this I don't think banning use of callbacks in
> one specific scenario is really beneficial in general - its really
> just a personal style choice.

I agree with Eric that in general loops are better than callbacks.
However, there are cases where iterators are just as awkward to write.
Considering that we have very few iterations on properties, I think your
patches are fine.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]