2 bool optional params

2010-11-09 Thread spir
Hello, Is there a way for a func to hold 2 optional params of the same type? void f(int p, bool b1=false, bool b2=false) { writefln("p=%s b1=%s b2=%s", p,b1,b2); } Or is there a workaroud? Denis -- -- -- -- -- -- -- vit esse estrany ☣ spir.wikidot.com

Re: Converting Fuse headers

2010-11-09 Thread Jesse Phillips
I have some good news! It works (Simplest test case). I spent several hours trying to track down where my code translation could be causing problems. And have concluded that core.sys.posix.sys.stat.stat_t is not correct for my 32bit Debian Linux machine. I realize this is a big claim, so I'm go

Re: ponce

2010-11-09 Thread Jonathan M Davis
On Tuesday, November 09, 2010 16:24:30 div0 wrote: > On 10/11/2010 00:16, Jonathan M Davis wrote: > > On Tuesday, November 09, 2010 13:49:12 bearophile wrote: > >> Jonathan M Davis: > >>> it would be possible to make it so that any objects allocated with > >>> new during CTFE would be in the dynami

Re: struct constructors and function parameters

2010-11-09 Thread Simen kjaeraas
Adam Burton wrote: I looked into alias this and it does indeed work, unless the alias is to a function. That has been reported as a bug though http://d.puremagic.com/issues/show_bug.cgi?id=2814 Wouldn't that be the opposite of what you were discussing earlier? alias this lets a struct behav

Re: struct constructors and function parameters

2010-11-09 Thread Adam Burton
Jonathan M Davis wrote: > On Tuesday, November 09, 2010 15:48:27 Adam Burton wrote: >> Hi, >> should the below work? >> >> struct A >> { >> public this(B b) {} >> } >> >> struct B {} >> >> void foo(A a) {} >> >> void main() >> { >> B b; >> foo(b); // Fails >> } >> >> The const

Re: ponce

2010-11-09 Thread div0
On 10/11/2010 00:16, Jonathan M Davis wrote: On Tuesday, November 09, 2010 13:49:12 bearophile wrote: Jonathan M Davis: it would be possible to make it so that any objects allocated with new during CTFE would be in the dynamic heap during runtime. This is possible, but it doesn't seem what yo

Re: struct constructors and function parameters

2010-11-09 Thread Simen kjaeraas
Adam Burton wrote: True, I had thought of that, but I figured in that situation it would favour int over foo (in same way long vs int) so to access foo you'd need to explicitly use the constructor. On the other hand I suppose its more of a difficult decision when you hit something like below

Re: struct constructors and function parameters

2010-11-09 Thread Jonathan M Davis
On Tuesday, November 09, 2010 15:48:27 Adam Burton wrote: > Hi, > should the below work? > > struct A > { > public this(B b) {} > } > > struct B {} > > void foo(A a) {} > > void main() > { > B b; > foo(b); // Fails > } > > The constructor parameter doesn't need to be a struct,

Re: ponce

2010-11-09 Thread Jonathan M Davis
On Tuesday, November 09, 2010 13:49:12 bearophile wrote: > Jonathan M Davis: > > it would be possible to make it so that any objects allocated with > > new during CTFE would be in the dynamic heap during runtime. > > This is possible, but it doesn't seem what you usually desire when you > allocate

Re: struct constructors and function parameters

2010-11-09 Thread div0
On 09/11/2010 23:57, Simen kjaeraas wrote: Adam Burton wrote: Hi, should the below work? struct A { public this(B b) {} } struct B {} void foo(A a) {} void main() { B b; foo(b); // Fails } The constructor parameter doesn't need to be a struct, it could be an int. The workaround is to expl

Re: struct constructors and function parameters

2010-11-09 Thread Adam Burton
Simen kjaeraas wrote: > Adam Burton wrote: > >> Hi, >> should the below work? >> >> struct A >> { >> public this(B b) {} >> } >> >> struct B {} >> >> void foo(A a) {} >> >> void main() >> { >> B b; >> foo(b); // Fails >> } >> >> The constructor parameter doesn't need to be a stru

Re: struct constructors and function parameters

2010-11-09 Thread Simen kjaeraas
Adam Burton wrote: Hi, should the below work? struct A { public this(B b) {} } struct B {} void foo(A a) {} void main() { B b; foo(b); // Fails } The constructor parameter doesn't need to be a struct, it could be an int. The workaround is to explicity call the constructo

Re: Converting Fuse headers

2010-11-09 Thread Simen kjaeraas
Jesse Phillips wrote: Can you forward declare a reference like this in D? If not does it matter what I define it to be? struct fuse {} // Since I'm really only passing pointers to this anyway. Sure hope this makes it work. It's completely safe to define it like that. Just don't do 'new fu

struct constructors and function parameters

2010-11-09 Thread Adam Burton
Hi, should the below work? struct A { public this(B b) {} } struct B {} void foo(A a) {} void main() { B b; foo(b); // Fails } The constructor parameter doesn't need to be a struct, it could be an int. The workaround is to explicity call the constructor.

Re: Converting Fuse headers

2010-11-09 Thread Jesse Phillips
Simen kjaeraas Wrote: > > The last one is the node structure[5]. Which I found in fuse.c[6] but > > seems to be used a lot so I don't no why it isn't in a header. > > Lemme guess, usually just the pointer is used? If so, it's hiding the > implementation. Just an indication you should never need

Re: Converting Fuse headers

2010-11-09 Thread Simen kjaeraas
Jesse Phillips wrote: hello_str = cast(char*) toStringz("Hello World!\n"); I stopped doing this, but I'm just wondering how you could get a modifiable C string if I needed one? If you already have a char[], just make sure it's terminated with a zero ('\0') character, and you can use yourCh

Re: Converting Fuse headers

2010-11-09 Thread Jesse Phillips
div0 Wrote: > Well I don't like to discourage people, but a casual glance at your post > and the fuse headers suggests to me you don't have nearly enough > experience of C to succeed. Thank you for the input. And I already figured quit a bit of effort would go into answering. I considered aski

Re: ponce

2010-11-09 Thread Don
bearophile wrote: Jonathan M Davis: it would be possible to make it so that any objects allocated with new during CTFE would be in the dynamic heap during runtime. This is possible, but it doesn't seem what you usually desire when you allocate an object at compile time. Bye, bearophile If

Re: ponce

2010-11-09 Thread bearophile
Jonathan M Davis: > it would be possible to make it so that any objects allocated with > new during CTFE would be in the dynamic heap during runtime. This is possible, but it doesn't seem what you usually desire when you allocate an object at compile time. Bye, bearophile

Re: Converting Fuse headers

2010-11-09 Thread div0
On 09/11/2010 05:49, Jesse Phillips wrote: Jesse Phillips Wrote: I'm trying to make fuse work in D[1]. I had some help from htod, but not everything was successful. And I'm not exactly sure how to properly convert strings and such. When saying D[1], I was referencing the link, not the versi

Re: ponce

2010-11-09 Thread Jonathan M Davis
On Tuesday 09 November 2010 12:42:06 bearophile wrote: > Don: > > Yes. The rules will be: > > * no globals (same as pure). > > * no unsafe features (eg, no asm). > > * source code must be available. > > Everything else should work. > > If a class is instantiated at compile-time the memory of its i

std.json

2010-11-09 Thread Bob Cowdery
Hi I'm trying to decode some json using std.json. I have figured out how to get at primitives out but can't get to a dictionary object. If I send something like {"mode":"am"} from my javascript and then say: value = parseJSON(message); I get a JSONValue struct. I can't find any documentation for

Re: ponce

2010-11-09 Thread bearophile
Don: > Yes. The rules will be: > * no globals (same as pure). > * no unsafe features (eg, no asm). > * source code must be available. > Everything else should work. If a class is instantiated at compile-time the memory of its instance goes in the static mutable memory, but then the GC has to man

Re: ponce

2010-11-09 Thread Don
bearophile wrote: ponce: Are these things possible at compile-time? 1 - instancing templated struct/class and using them Currently classes can't be created at compile time, this fails: class Foo {} int bar() { Foo f = new Foo; return 0; } enum int ignore = bar(); void main() {} Bu

Re: ponce

2010-11-09 Thread bearophile
ponce: > Are these things possible at compile-time? > 1 - instancing templated struct/class and using them Currently classes can't be created at compile time, this fails: class Foo {} int bar() { Foo f = new Foo; return 0; } enum int ignore = bar(); void main() {} But this limit may b

Re: multiple alias this in class/struct not allowed?

2010-11-09 Thread Don
Adam Cigánek wrote: Ok guys, thanks. Got it. Well, good to know. Any chance of knowing when could this feature be implemented? First half of next year. adam. 2010/11/9 Jonathan M Davis : In most cases, dmd matches up with TDPL already, but there are several cases where it hasn't caught up

ponce

2010-11-09 Thread Is this possible at compile time?
Are these things possible at compile-time? 1 - instancing templated struct/class and using them 2 - calling dynamically linked C functions 3 - accessing files thanks for answers

Re: ponce

2010-11-09 Thread Simen kjaeraas
Is this possible at compile time? wrote: Are these things possible at compile-time? 1 - instancing templated struct/class and using them Structs yes, classes no. And not all kinds. 2 - calling dynamically linked C functions No. 3 - accessing files Yes. import( "filename" ) gives you t

Re: ponce

2010-11-09 Thread Is this possible at compile time?
Sorry I swapped the topic and user name fields :|

Re: multiple alias this in class/struct not allowed?

2010-11-09 Thread Adam Cigánek
Ok guys, thanks. Got it. Well, good to know. Any chance of knowing when could this feature be implemented? adam. 2010/11/9 Jonathan M Davis : > On Monday, November 08, 2010 13:49:36 Adam Cigánek wrote: >> Hello, >> >> Why are multiple alias this declarations in a class/struct not >> allowed? This

Re: Pure and C functions

2010-11-09 Thread Don
Jonathan M Davis wrote: Is there any way to make a function which calls C functions pure? - Jonathan M Davis Just mark the C function as pure, if it's truly pure. If it isn't really pure, you'll have to use a cast (eg, by taking its address and then casting the function pointer).