Re: Passing Obj-C method as callback to C function
Re: Passing Obj-C method as callback to C function
- Subject: Re: Passing Obj-C method as callback to C function
- From: Christian Brunschen <email@hidden>
- Date: Wed, 29 Oct 2003 10:02:43 +0100 (MET)
On Tue, 28 Oct 2003 email@hidden wrote:
>
Which means we should be able to have Smalltalk-style blocks now. Just
>
need the syntactic sugar.
>
>
Something like
>
>
[array do: @[:each | some code goes here]]
>
>
would be really nifty (ie a block is @[])
>
>
I wonder what's holding that up?
The lack of a real need for Smalltalk-style Blocks, probably. After all,
in Smalltalk, Blocks are needed for basic things like iteration,
conditionals, etc. Objective-C, however, uses C's constructs for those,
removing the need for Blocks.
Things like [array do:...] can actually be done differently, using
concepts like Higher-Order Messaging.
And indeed anything you might want to use a Block for can actually be done
using a plain C function. So we already _have_ a construct, and don't
really need to introduce another one.
Many uses of Blocks also lead to a code clutter: code that serves one
purpose being written within a method that actually does something else.
In such cases I find it better to separate the code that would have beel
placed in a Block, in a method or function of its own; this can then also
be debugged and reused much more easily.
Best wishes,
// Christian Brunschen
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.