On Sun, 25 Jan 2015 20:42:47 +, Dominikus Dittes Scherkl wrote:
> But in a function you need the cast anyway:
> ubyte swapNibbles(ubyte x) { return (x>>4) | (x>>4); } // compiler not
> happy
sure, it can't be happy, as `x` is promoted to int in the expression, so
the expression result is `int
On Sunday, 25 January 2015 at 18:59:04 UTC, ketmar wrote:
auto x2 = (x>>4) | (x<<4); // swap nibbles - but result in an
int!
this is true for C and C++ too, as all three languages doing
"integer
promotion". the only difference is that D forbids potentially
lossy
assigns.
you best bet is
On Sun, 25 Jan 2015 14:11:09 +, Dominikus Dittes Scherkl wrote:
> On Sunday, 25 January 2015 at 13:03:16 UTC, bearophile wrote:
>> Dominikus Dittes Scherkl:
>>
>>> Because this is useful in more situations,
>>
>> Right, but it's still a cast. And in D you want to minimize the number
>> of usag
On Sunday, 25 January 2015 at 13:03:16 UTC, bearophile wrote:
Dominikus Dittes Scherkl:
Because this is useful in more situations,
Right, but it's still a cast. And in D you want to minimize the
number of usages of casts. The proposed syntax iota!"[]" is
cast-safe.
I don't case too much,
On Sunday, 25 January 2015 at 12:56:14 UTC, Tobias Pankrath wrote:
On Sunday, 25 January 2015 at 12:25:35 UTC, Dominikus Dittes
Scherkl wrote:
map!(x => fn(cast(ParameterTypeTuple!fn[0])x)
but instead with
map!(paramCast!fn)
Because this is useful in more situations, e.g. in every place
whe
Dominikus Dittes Scherkl:
Because this is useful in more situations,
Right, but it's still a cast. And in D you want to minimize the
number of usages of casts. The proposed syntax iota!"[]" is
cast-safe.
Bye,
bearophile
On Sunday, 25 January 2015 at 12:25:35 UTC, Dominikus Dittes
Scherkl wrote:
map!(x => fn(cast(ParameterTypeTuple!fn[0])x)
but instead with
map!(paramCast!fn)
Because this is useful in more situations, e.g. in every place
where you know the values would fit into the parameter (and for
a sing
On Sunday, 25 January 2015 at 10:42:51 UTC, bearophile wrote:
Vlad Levenfeld:
What's this about !`[]` and std.range.uniform?? It's not in
the documentation.
It's an enhancement I have proposed.
Hm. I had more something in mind like "paramCast" - a kind of big
scissors that cut everything a
Vlad Levenfeld:
What's this about !`[]` and std.range.uniform?? It's not in the
documentation.
It's an enhancement I have proposed.
Bye,
bearophile
you can always write your own iota replacement, which will do
"[]" and
use ubytes, for example. writing that things is way easier than
in C++.
something like "myIota!ubyte(0, 255)", for example -- to make
it visible
that it emits ubytes.
I think closedInterval!T (T left, T right) would be a
On Sun, 25 Jan 2015 00:12:18 +, Dominikus Dittes Scherkl wrote:
> On Saturday, 24 January 2015 at 23:19:11 UTC, ketmar wrote:
>> people that are new to D aren't used to D lambdas, so it's fairly
>> common.
> Oh, I am aware, but I didn't thought it would be necessary in this pace.
>
>> if you'
On Saturday, 24 January 2015 at 23:19:11 UTC, ketmar wrote:
people that are new to D aren't used to D lambdas, so it's
fairly common.
Oh, I am aware, but I didn't thought it would be necessary in
this pace.
if you'll stay with D, you'll find yourself dreaming about such
handy thing in another
On Sat, 24 Jan 2015 22:57:57 +, Dominikus Dittes Scherkl wrote:
> On Saturday, 24 January 2015 at 21:00:06 UTC, Tobias Pankrath wrote:
>> On Saturday, 24 January 2015 at 20:49:03 UTC, Dominikus Dittes Scherkl
>> wrote:
>>> I would have no problem using an explicit cast, but where should I
>>>
On Saturday, 24 January 2015 at 21:00:06 UTC, Tobias Pankrath
wrote:
On Saturday, 24 January 2015 at 20:49:03 UTC, Dominikus Dittes
Scherkl wrote:
I would have no problem using an explicit cast, but where
should I apply it?
iota(0, 256).map!(x => foo(cast(ubyte) x))
Ok, thank you very much.
juicy question!
signature.asc
Description: PGP signature
On Sat, 24 Jan 2015 20:49:01 +, Dominikus Dittes Scherkl wrote:
> Maybe I'm just too stupid, but I cannot manage to call a simple function
> with all 256 possible values of ubyte with iote:
>
> int foo(ubyte c);
>
> auto myRange = iota(0,256).map!foo;
>
> --> Error: function foo(ubyte c) i
On Saturday, 24 January 2015 at 20:49:03 UTC, Dominikus Dittes
Scherkl wrote:
Maybe I'm just too stupid, but I cannot manage to call a simple
function
with all 256 possible values of ubyte with iote:
int foo(ubyte c);
auto myRange = iota(0,256).map!foo;
--> Error: function foo(ubyte c) is no
Dominikus Dittes Scherkl:
Has anyone any idea how to work around this?
In Bugzilla I have proposed to solve this problem with this
syntax taken from std.range.uniform:
iota!"[]"(ubyte.min, ubyte.max)
Bye,
bearophile
On Sat, Jan 24, 2015 at 08:49:01PM +, Dominikus Dittes Scherkl via
Digitalmars-d-learn wrote:
> Maybe I'm just too stupid, but I cannot manage to call a simple function
> with all 256 possible values of ubyte with iote:
>
> int foo(ubyte c);
>
> auto myRange = iota(0,256).map!foo;
[...]
Try
19 matches
Mail list logo