Does dmd have SSE intrinsics?
Michel Fortin
michel.fortin at michelf.com
Wed Sep 23 05:12:47 PDT 2009
On 2009-09-22 12:32:25 -0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> said:
> Daniel Keep wrote:
>> P.S. And another thing while I'm at it: why can't we declare void
>> variables? This is another thing that really complicates generic code.
>
> How would you use them?
Here's some generic code that would benefit from void as a variable
type in the D/Objective-C bridge. Basically, it keeps the result of a
function call, does some cleaning, and returns the result (with value
conversions if needed). Unfortunately, you need a separate path for
functions that returns void:
// Call Objective-C code that may raise an exception here.
static if (is(R == void)) func(objcArgs);
else ObjcType!(R) objcResult = func(objcArgs);
_NSRemoveHandler2(&_localHandler);
// Converting return value.
static if (is(R == void)) return;
else return decapsulate!(R)(objcResult);
It could be rewriten in a simpler way if void variables were supported:
// Call Objective-C code that may raise an exception here.
ObjcType!(R) objcResult = func(objcArgs);
_NSRemoveHandler2(&_localHandler);
// Converting return value.
return decapsulate!(R)(objcResult);
Note that returning a void resulting from a function call already works
in D. You just can't "store" the result of such functions in a variable.
That said, it's not a big hassle in this case, thanks to static if.
What suffers most is code readability.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list