On Sun, 07 Apr 2013 01:53:34 +0200
"bearophile" wrote:
> Nick Sabalausky:
>
> > I have a feeling I'm missing something obvious, but how do I
> > create
> > something like this?:
> >
> > class Foo(TArgs...)
> > {
> > void func(/+ args must exactly match TArgs +/)
> > {
> > }
> > }
>
Timothee Cour:
* it breaks _orthogonality_ of features: opIndex should work
with
everything (indexes, slices), whereas now we're having an
opSliceIndex
that works on slices and opIndex that works on non-slices.
Don has discussed about this more than one time. Generally I
think there is spac
Nick Sabalausky:
I have a feeling I'm missing something obvious, but how do I
create
something like this?:
class Foo(TArgs...)
{
void func(/+ args must exactly match TArgs +/)
{
}
}
new Foo(int).func(5); // Ok
new Foo(int, string).func(5, "hello"); // Ok
// Error! Overload not fo
I have a feeling I'm missing something obvious, but how do I create
something like this?:
class Foo(TArgs...)
{
void func(/+ args must exactly match TArgs +/)
{
}
}
new Foo(int).func(5); // Ok
new Foo(int, string).func(5, "hello"); // Ok
// Error! Overload not found!
new Foo(int).fun
Currently x[a...b] calls opSlice(a,b);
This has several drawbacks:
* it breaks _orthogonality_ of features: opIndex should work with
everything (indexes, slices), whereas now we're having an opSliceIndex
that works on slices and opIndex that works on non-slices.
* one can't have multiple slicing
cal:
Ah thank you, I did not realize a call to front was required.
Whenever you can, don't create side effects inside a map(). It
will not work reliably. A higher order function like map is not
meant to be used that way.
Bye,
bearophile
On Saturday, 6 April 2013 at 21:40:37 UTC, bearophile wrote:
First, to see the side effects you have also to call front:
Ah thank you, I did not realize a call to front was required.
But this is wrong still. map() is a higher order function, it's
meant to take a function and an iterable and p
cal:
Should the code below print anything (it currently doesn't)?
I'm not sure I understand map:
import std.stdio, std.algorithm;
void main() {
int[] a = [1,2,3,4,5];
auto r = a.map!( i => writeln(i) );
while(!r.empty) r.popFront();
}
The code is working as requested. Bu
Should the code below print anything (it currently doesn't)? I'm
not sure I understand map:
import std.stdio, std.algorithm;
void main() {
int[] a = [1,2,3,4,5];
auto r = a.map!( i => writeln(i) );
while(!r.empty) r.popFront();
}
On Saturday, 6 April 2013 at 15:38:55 UTC, Tobias Pankrath wrote:
Is there however some way to generate that switch with cases
for each enum member in a template, so that each case calls
(Machine)() instantiated with the
appropriate enum member? I know you could do it with string
mixins, but
Is there however some way to generate that switch with cases
for each enum member in a template, so that each case calls
(Machine)() instantiated with the
appropriate enum member? I know you could do it with string
mixins, but that be a hassle to implement...
Eventually, I want my code to l
On Friday, 5 April 2013 at 18:00:56 UTC, bearophile wrote:
Sebastian Graf:
I wonder if there is a good way to dry up this:
I suggest to improve that code a lot.
For machineWord there is:
alias machineWord = Select!(machine == Machine.I386, uint,
ulong);
This:
(1 << 32)
Gives:
Error: shi
Jos van Uden:
http://rosettacode.org/wiki/Set_puzzle#Alternative_Version
Ledrug tagged it. The output says: striped open open. That
shouldn't happen.
I don't know what's wrong, and why, so I've killed that
alternative version...
Bye,
bearophile
13 matches
Mail list logo