On Saturday, 25 February 2012 at 16:26:05 UTC, Ashish Myles wrote:
2. Secondly, TDPL on page 381 says that foreach iterates over
C[], if
C defines the opSlice() function without any arguments.
However the code above doesn't seem to work and requires me to
explicitly invoke the slice opera
On 26-02-2012 02:54, Jonathan M Davis wrote:
On Saturday, February 25, 2012 17:54:44 H. S. Teoh wrote:
On Sun, Feb 26, 2012 at 12:23:47AM +0100, Alex Rønne Petersen wrote:
On 26-02-2012 00:18, Jonathan M Davis wrote:
On Saturday, February 25, 2012 17:07:14 Timon Gehr wrote:
This is useful:
s
On Sat, Feb 25, 2012 at 4:45 PM, DNewbie wrote:
>
>
> On Sat, Feb 25, 2012, at 10:38 PM, Mars wrote:
>> On Saturday, 25 February 2012 at 18:27:29 UTC, Vladimir Panteleev
>> wrote:
>> > On Friday, 24 February 2012 at 19:15:26 UTC, Mars wrote:
>> >> Hello everybody.
>> >>
>> >> When trying to compil
On Saturday, February 25, 2012 17:54:44 H. S. Teoh wrote:
> On Sun, Feb 26, 2012 at 12:23:47AM +0100, Alex Rønne Petersen wrote:
> > On 26-02-2012 00:18, Jonathan M Davis wrote:
> > >On Saturday, February 25, 2012 17:07:14 Timon Gehr wrote:
> > >>This is useful:
> > >>
> > >>struct S{
> > >>
> > >>
On Sun, Feb 26, 2012 at 12:23:47AM +0100, Alex Rønne Petersen wrote:
> On 26-02-2012 00:18, Jonathan M Davis wrote:
> >On Saturday, February 25, 2012 17:07:14 Timon Gehr wrote:
> >>This is useful:
> >>
> >>struct S{
> >> @disable enum init = 0;
> >>}
> >
> >I thought that the way that you were
On 2/25/12, Ali Çehreli wrote:
> Apparently template parameters
> with default values need not be at the end of the template parameter list
Well it would make variadic templates rather hard to use if this was illegal:
void print(bool pretty = false, T...)(T args) { }
void main() { print(1, "two"
On Saturday, 25 February 2012 at 23:10:51 UTC, Ary Manzana wrote:
On 2/25/12 7:31 PM, Robert Rouse wrote:
On Saturday, 25 February 2012 at 22:12:55 UTC, Ali Çehreli
wrote:
On 02/25/2012 01:55 PM, Robert Rouse wrote:
On Saturday, 25 February 2012 at 18:54:35 UTC, Trass3r wrote:
void foo(T,
On 02/25/2012 03:00 PM, Andrej Mitrovic wrote:
On 2/25/12, Ali Çehreli wrote:
But there is no way for fwrite to follow name.ptr to also write the
characters that are in the string, right?
Oh my I just got a big fat zero on the finals. You're absolutely
right, what gets copied is the length an
On 26-02-2012 00:18, Jonathan M Davis wrote:
On Saturday, February 25, 2012 17:07:14 Timon Gehr wrote:
This is useful:
struct S{
@disable enum init = 0;
}
I thought that the way that you were supposed to do that was
@disable this();
- Jonathan M Davis
Yeah, I'm not sure what purpose
On Saturday, February 25, 2012 17:07:14 Timon Gehr wrote:
> This is useful:
>
> struct S{
> @disable enum init = 0;
> }
I thought that the way that you were supposed to do that was
@disable this();
- Jonathan M Davis
On 2/25/12 7:31 PM, Robert Rouse wrote:
On Saturday, 25 February 2012 at 22:12:55 UTC, Ali Çehreli wrote:
On 02/25/2012 01:55 PM, Robert Rouse wrote:
On Saturday, 25 February 2012 at 18:54:35 UTC, Trass3r wrote:
void foo(T, T2, alias thing = (){})(T a, T2 b)
{
thing();
}
void bar(){}
void
On 2/25/12, Andrej Mitrovic wrote:
> I'm not sure where you're getting that from:
Let that be a classic lesson on what never to do. Here's a
demonstration on how wrong I was:
import std.stdio;
struct Foo
{
char[] name;
}
void main(string[] args)
{
if (args[1] == "write")
{
Foo
On 2/26/12, Andrej Mitrovic wrote:
> allocated on the stack
Sorry, I meant the data segment not the stack. That's -1 score for me.
On 2/25/12, Ali Çehreli wrote:
> But there is no way for fwrite to follow name.ptr to also write the
> characters that are in the string, right?
Oh my I just got a big fat zero on the finals. You're absolutely
right, what gets copied is the length and the pointer. The only reason
my last sample w
On Sat, Feb 25, 2012, at 10:38 PM, Mars wrote:
> On Saturday, 25 February 2012 at 18:27:29 UTC, Vladimir Panteleev
> wrote:
> > On Friday, 24 February 2012 at 19:15:26 UTC, Mars wrote:
> >> Hello everybody.
> >>
> >> When trying to compile a program using GDC (Windows), which
> >> includes an i
To be honest the C fread and fwrite aren't even necessary since you
can do a rawRead and rawWrite instead.
On 2/25/12, Ali Çehreli wrote:
> That passes because lal.name.ptr and dup.name.ptr have the same value.
> Maybe that wasn't the intention but the data is not really in the file.
I'm not sure where you're getting that from:
import std.stdio;
struct nagger
{
string name;
int age;
doub
On Saturday, 25 February 2012 at 22:12:55 UTC, Ali Çehreli wrote:
On 02/25/2012 01:55 PM, Robert Rouse wrote:
On Saturday, 25 February 2012 at 18:54:35 UTC, Trass3r wrote:
void foo(T, T2, alias thing = (){})(T a, T2 b)
{
thing();
}
void bar(){}
void main()
{
foo!(int,int,bar)(1,2);
foo(1,2)
On 02/25/2012 01:55 PM, Robert Rouse wrote:
On Saturday, 25 February 2012 at 18:54:35 UTC, Trass3r wrote:
void foo(T, T2, alias thing = (){})(T a, T2 b)
{
thing();
}
void bar(){}
void main()
{
foo!(int,int,bar)(1,2);
foo(1,2);
}
Cool. Didn't know you can do that, but I guess it makes sense t
On 02/25/2012 10:33 AM, Andrej Mitrovic wrote:
Well first I'd recommend not allocating the struct on the heap. Then you can do:
import std.stdio;
struct nagger
{
string name;
int age;
double weight;
string msg;
}
void main()
{
nagger lal;
lal.name = "name";
On Saturday, 25 February 2012 at 18:54:35 UTC, Trass3r wrote:
void foo(T, T2, alias thing = (){})(T a, T2 b)
{
thing();
}
void bar(){}
void main()
{
foo!(int,int,bar)(1,2);
foo(1,2);
}
Cool. Didn't know you can do that, but I guess it makes sense
that it would work th
On Saturday, 25 February 2012 at 18:27:29 UTC, Vladimir Panteleev
wrote:
On Friday, 24 February 2012 at 19:15:26 UTC, Mars wrote:
Hello everybody.
When trying to compile a program using GDC (Windows), which
includes an import std.socket, I get a lot "undefined
reference"s, like
undefined ref
On 25.02.2012 8:05, bearophile wrote:
This program comes from a reduction of a bug I've found:
struct Foo {
void init() {}
}
void main() {
Foo*[] foos;
//(*foos[0]).init(); // OK
foos[0].init(); // Error: function expected before (), not null of type
Foo*
}
What do you th
On 25.02.2012 20:25, Ashish Myles wrote:
I want to define a general-purpose centroid computer for point containers
and ran into a couple of challenges. Firstly, here is the basic code
Point3 computeCentroid(PointContainer)(const ref PointContainer C)
if (...)// want a signature
On Sat, Feb 25, 2012 at 11:37 AM, Alex Rønne Petersen
wrote:
> On 25-02-2012 17:25, Ashish Myles wrote:
>>
>> 1. Since support for foreach can be added in many ways (with
>> ref/non-ref/const variants), I wanted to check if there was any
>> signature constraint that could check if the containe
void foo(T, T2, alias thing = (){})(T a, T2 b)
{
thing();
}
void bar(){}
void main()
{
foo!(int,int,bar)(1,2);
foo(1,2);
}
Is it possible to do something like this?
void foo(T, T2, alias thing)(T a, T2 b) {
// do stuff with a
// call b (since b would be a delegate)
// call thing if thing is given
}
I come from the Ruby world and I'm just playing around to see how
much I can replicate of the "block" functional
On Sat, 25 Feb 2012 17:12:50 +0100, Timon Gehr wrote:
On 02/24/2012 07:22 PM, simendsjo wrote:
I have a C function taking a callback function as a parameter. My
thought was to wrap this up using a template, but I cannot get it to
work:
extern(C) alias void function() Callback;
template Wr
On 2/25/12, Andrej Mitrovic wrote:
> This doesn't work for heap-allocated structs.
>
Sorry my bad. .sizeof should always be set on Types and not variable
names, because a struct pointer will have sizeof == size_t, whereas a
simple struct variable will have sizeof equal to the struct size. So
it c
Well first I'd recommend not allocating the struct on the heap. Then you can do:
import std.stdio;
struct nagger
{
string name;
int age;
double weight;
string msg;
}
void main()
{
nagger lal;
lal.name = "name";
lal.age= 23;
lal.weight = 108.5;
lal.msg
On Friday, 24 February 2012 at 19:15:26 UTC, Mars wrote:
Hello everybody.
When trying to compile a program using GDC (Windows), which
includes an import std.socket, I get a lot "undefined
reference"s, like
undefined reference to `WSAGetLastError@0'
Try linking with libws2_32.a.
On 02/25/2012 07:23 PM, Artur Skawina wrote:
On 02/25/12 15:37, Timon Gehr wrote:
On 02/25/2012 03:32 PM, Stewart Gordon wrote:
On 21/02/2012 17:46, Jacob Carlborg wrote:
On 2012-02-21 16:55, deadalnix wrote:
You can implement a static opCall and use that instead of the
constructor.
But y
On 02/25/12 15:37, Timon Gehr wrote:
> On 02/25/2012 03:32 PM, Stewart Gordon wrote:
>> On 21/02/2012 17:46, Jacob Carlborg wrote:
>>> On 2012-02-21 16:55, deadalnix wrote:
>>
>>> You can implement a static opCall and use that instead of the
>>> constructor.
>>
>> But you don't have to call a stat
On 02/25/2012 07:15 PM, Timon Gehr wrote:
On 02/25/2012 07:03 PM, Chopin wrote:
Hello!
import std.stdio;
struct nagger
{
string name;
int age;
double weight;
string msg;
}
void main()
{
auto lal = new nagger();
lal.name = "AHAHAHAHHA";
lal.age = 23;
lal.weight = 108.5;
lal.msg = "fgfdgfdgfdgf
On 02/25/2012 07:03 PM, Chopin wrote:
Hello!
import std.stdio;
struct nagger
{
string name;
int age;
double weight;
string msg;
}
void main()
{
auto lal = new nagger();
lal.name = "AHAHAHAHHA";
lal.age = 23;
lal.weight = 108.5;
lal.msg = "fgfdgfdgfdgfdgfdgfdg";
writeln(cast(ubyte[])(lal));
}
Hello!
import std.stdio;
struct nagger
{
string name;
int age;
double weight;
string msg;
}
void main()
{
auto lal = new nagger();
lal.name = "AHAHAHAHHA";
lal.age = 23;
lal.weight = 108.5;
lal.msg = "fgfdgfdgfdgfdgfdgfdg";
writeln(cast(ubyte[])(lal));
}
On 25-02-2012 17:25, Ashish Myles wrote:
I want to define a general-purpose centroid computer for point containers
and ran into a couple of challenges. Firstly, here is the basic code
Point3 computeCentroid(PointContainer)(const ref PointContainer C)
if (...)// want a signature
I want to define a general-purpose centroid computer for point containers
and ran into a couple of challenges. Firstly, here is the basic code
Point3 computeCentroid(PointContainer)(const ref PointContainer C)
if (...)// want a signature constraint for usability of foreach
{
On 02/24/2012 07:22 PM, simendsjo wrote:
I have a C function taking a callback function as a parameter. My
thought was to wrap this up using a template, but I cannot get it to work:
extern(C) alias void function() Callback;
template Wrap(alias dg)
{
extern(C) void Wrap()
{
dg();
}
}
void main(
On 02/25/2012 04:52 PM, H. S. Teoh wrote:
On Sat, Feb 25, 2012 at 01:23:21PM +0100, Alex Rønne Petersen wrote:
On 25-02-2012 05:05, bearophile wrote:
This program comes from a reduction of a bug I've found:
struct Foo {
void init() {}
}
void main() {
Foo*[] foos;
//(*foos[0]).i
On Sat, Feb 25, 2012 at 01:23:21PM +0100, Alex Rønne Petersen wrote:
> On 25-02-2012 05:05, bearophile wrote:
> >This program comes from a reduction of a bug I've found:
> >
> >
> >struct Foo {
> > void init() {}
> >}
> >void main() {
> > Foo*[] foos;
> > //(*foos[0]).init(); // OK
> >
On 2012-02-24 23:37, Ellery Newcomer wrote:
So I'm all trying out this hot new shared switch, and it works just
dandy for -m32 when d has the main function. But now I want to be able
to call my shared lib from C.
my little shared lib, tup.d:
import std.stdio;
extern(C) void xyz(int i){
writeln
On 02/22/2012 01:13 AM, BLM wrote:
That last one looks a lot better than my solution. It's certainly a lot clearer.
One problem I discovered with using templates was that I ended up needing
virtual
functions, which means that I had to convert the template functions to mixins
and
just instantia
On 02/25/2012 03:32 PM, Stewart Gordon wrote:
On 21/02/2012 17:46, Jacob Carlborg wrote:
On 2012-02-21 16:55, deadalnix wrote:
You can implement a static opCall and use that instead of the
constructor.
But you don't have to call a static opCall. You can just declare a
struct instance withou
On 21/02/2012 17:46, Jacob Carlborg wrote:
On 2012-02-21 16:55, deadalnix wrote:
You can implement a static opCall and use that instead of the constructor.
But you don't have to call a static opCall. You can just declare a struct instance
without any initialisation. Presumably half the po
On 25-02-2012 05:05, bearophile wrote:
This program comes from a reduction of a bug I've found:
struct Foo {
void init() {}
}
void main() {
Foo*[] foos;
//(*foos[0]).init(); // OK
foos[0].init(); // Error: function expected before (), not null of type
Foo*
}
What do you t
46 matches
Mail list logo