On 07/12/2010 17:29, spir wrote:
Hello D people,
Is there a way to unpack an array into local vars, as:
auto x = [1,2,3];
a,b,c = x;
import std.stdio;
void unpack(A, T...)(out T vars, A data) {
assert (vars.length == data.length);
foreach (i, v; vars) {
vars[i]
Andrej Mitrovic wrote:
Cool! But, when is "ctod.exe" coming out? :p
That should have been "cpptod". ;)
As soon as you write it.
--
Simen
On 12/8/10, Andrej Mitrovic wrote:
> On 12/8/10, Walter Bright wrote:
>> Andrej Mitrovic wrote:
>>> I haven't tried but maybe htod can help, try copypasting the code to a
>>> header file and run it through htod. There's also some flags htod can
>>> take to simplify the output, iirc. But maybe hto
On 12/8/10, Walter Bright wrote:
> Andrej Mitrovic wrote:
>> I haven't tried but maybe htod can help, try copypasting the code to a
>> header file and run it through htod. There's also some flags htod can
>> take to simplify the output, iirc. But maybe htod isn't clever enough
>> to do bitfields..
Andrej Mitrovic wrote:
I haven't tried but maybe htod can help, try copypasting the code to a
header file and run it through htod. There's also some flags htod can
take to simplify the output, iirc. But maybe htod isn't clever enough
to do bitfields..
htod does bitfields. Give it a try!
Jonathan M Davis Wrote:
> Okay. I'm trying to get some C code to be properly callable from some D code,
> which naturally involves some extern(C) blocks. One of the types that I have
> to
> deal with looks something like this:
>
> typedef struct
> {
> unsigned i:1;
> } my_s
Stanislav Blinov wrote:
>> But bitfields in C may not use the same alignments used by
>> bitfields!() on DMD so I think you have to test the sanity of the
>> whole thing for each combination of D compiler, operating system and C
>> compiler.
>
> hm... what alignments are you talking about? bitfie
bearophile wrote:
Stanislav Blinov:
I'm under the impression that
struct my_struct
{
mixin(bitfields!(
uint, "i", 1,
uint, "", 31));
}
should do the trick.
But bitfields in C may not use the same alignments used by bitfields!() on DMD
so I think you have to test the sanity of the whole thi
On Tue, 07 Dec 2010 16:20:45 +0100
Lutger Blijdestijn wrote:
> Lutger Blijdestijn wrote:
>
> > spir wrote:
> >
> >> On Tue, 07 Dec 2010 13:44:18 +0100
> >> Lutger Blijdestijn wrote:
> >>
> >>> There are some other conditions that prevent inlining, it's best to
> >>> check for it. iirc also fu
On Tuesday, December 07, 2010 10:10:31 spir wrote:
> Hello again,
>
> I started to be found of defining types which basically are arrays with
> free functions, instead of creating a struct or class with methods. Not
> only we still have pseudo-method syntax (for arrays only), but this allows
> cus
Stanislav Blinov:
> I'm under the impression that
>
> struct my_struct
> {
> mixin(bitfields!(
> uint, "i", 1,
> uint, "", 31));
> }
>
> should do the trick.
But bitfields in C may not use the same alignments used by bitfields!() on DMD
so I think you have to test the sanity of the whole thing
spir:
> But: is there a way to define functions corresponding to language operations
> (opEquals, opIndex, toString...) without creating a true type?
You may find some trick to do something like that, but it's not how D is
supposed to be used. In D operators belong in a struct/class/enum. "alia
spir:
> Is there a way to unpack an array into local vars, as:
> auto x = [1,2,3];
> a,b,c = x;
Not yet, but I have asked this feature for tuples too and maybe someone has
appreciated it.
Bye,
bearophile
Hello again,
I started to be found of defining types which basically are arrays with free
functions, instead of creating a struct or class with methods. Not only we
still have pseudo-method syntax (for arrays only), but this allows customizing
the type when needed.
But: is there a way to define
On Tuesday, December 07, 2010 09:29:18 spir wrote:
> Hello D people,
>
> Is there a way to unpack an array into local vars, as:
> auto x = [1,2,3];
> a,b,c = x;
No. There is no way to do multiple assignments to the left of an assignment
operator. The only way that you can do multiple
Hello D people,
Is there a way to unpack an array into local vars, as:
auto x = [1,2,3];
a,b,c = x;
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com
I haven't tried but maybe htod can help, try copypasting the code to a
header file and run it through htod. There's also some flags htod can
take to simplify the output, iirc. But maybe htod isn't clever enough
to do bitfields..
On 12/7/10, Stanislav Blinov wrote:
> 07.12.2010 11:58, Jonathan M D
Lutger Blijdestijn wrote:
> spir wrote:
>
>> On Tue, 07 Dec 2010 13:44:18 +0100
>> Lutger Blijdestijn wrote:
>>
>>> There are some other conditions that prevent inlining, it's best to
>>> check for it. iirc also functions with loops, delegate and ref
>>> parameters cannot be inlined for example
spir wrote:
> On Tue, 07 Dec 2010 13:44:18 +0100
> Lutger Blijdestijn wrote:
>
>> There are some other conditions that prevent inlining, it's best to check
>> for it. iirc also functions with loops, delegate and ref parameters
>> cannot be inlined for example. I'm not so sure about ref, that may
06.12.2010 22:11, Adam Ruppe пишет:
Is there a thing like C's exit() for a D program? Is
simply using C's function good enough?
Also take a look at core.runtime.Runtime.terminate()
07.12.2010 11:58, Jonathan M Davis пишет:
Okay. I'm trying to get some C code to be properly callable from some D code,
which naturally involves some extern(C) blocks. One of the types that I have to
deal with looks something like this:
typedef struct
{
unsigned i:1;
} my
On Tue, 07 Dec 2010 13:44:18 +0100
Lutger Blijdestijn wrote:
> There are some other conditions that prevent inlining, it's best to check
> for it. iirc also functions with loops, delegate and ref parameters cannot
> be inlined for example. I'm not so sure about ref, that may have been
> improv
Jonathan M Davis wrote:
> On Tuesday 07 December 2010 03:05:28 spir wrote:
>> Hello,
>>
>> Does dmd inline when appropriate (eg single-line func)? or is there a
>> hint keyword? or what else? Eg how to have this inlined:
>>
>> private bool isPrecomposedHangulSylable (Code code) {
>> /** whet
On Tuesday 07 December 2010 03:05:28 spir wrote:
> Hello,
>
> Does dmd inline when appropriate (eg single-line func)? or is there a hint
> keyword? or what else? Eg how to have this inlined:
>
> private bool isPrecomposedHangulSylable (Code code) {
> /** whether code is a precomposed Hangul s
On 12/07/10 05:05, spir wrote:
> Hello,
>
> Does dmd inline when appropriate (eg single-line func)? or is there a hint
> keyword? or what else?
> Eg how to have this inlined:
>
> private bool isPrecomposedHangulSylable (Code code) {
> /** whether code is a precomposed Hangul syllable ;-) */
Hello,
Does dmd inline when appropriate (eg single-line func)? or is there a hint
keyword? or what else?
Eg how to have this inlined:
private bool isPrecomposedHangulSylable (Code code) {
/** whether code is a precomposed Hangul syllable ;-) */
return (code >= FIRST_HANGUL_SYLLABLE) && (
Okay. I'm trying to get some C code to be properly callable from some D code,
which naturally involves some extern(C) blocks. One of the types that I have to
deal with looks something like this:
typedef struct
{
unsigned i:1;
} my_struct;
I have no idea how to do such a bitf
27 matches
Mail list logo