using the full range of ubyte with iota

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jan 24 16:24:04 PST 2015


On Sun, 25 Jan 2015 00:12:18 +0000, 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'll stay with D, you'll find yourself dreaming about such handy
>> thing in another compiled languages very soon. ;-)
> 
> I don't consider to use any other language as long as I have a choice
> :-)
> 
> But in the end, my one short and beautiful solution
> 
> auto myRange = iota(start, end).map!foo;
> 
> changed into something quite klumsy:
> 
> auto myRange = iota(start, end).map!(x =>
> foo(cast(ParameterTypeTuple!foo[0])x));
> 
> which I think is against the philosophy of D as it turns away the eye of
> the reader from what is really going on, especially if previous
> constraints ensured that start and end-1 are of the correct type :-(
> 
> But ok, still far, far better than what would be neccessary in C++

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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150125/201bb1d4/attachment.sig>


More information about the Digitalmars-d-learn mailing list