Re: easy way to output a struct?

2009-01-15 Thread Hoenir
Thanks for your explanation. Is there any good resource about that stuff other than http://www.digitalmars.com/d/1.0/template.html

Re: confused with some_var.dup

2009-01-15 Thread Tim M
On Fri, 16 Jan 2009 20:30:53 +1300, Qian Xu wrote: When shall I use some_var.dup and when not? Is there any guidlines? --Qian Yeah when you want one to be different than the other. If the lvalue is a slice then there is no need though.

Re: Getting line number where error occured?

2009-01-15 Thread Hoenir
Jarrett Billingsley schrieb: Team0xf has made a few traceback modules which work only with Tango on Windows to fill in this info, but there's no reason it couldn't be done on other platforms or with Phobos. only with Tango? I've also seen some Phobos hacks on their site.

confused with some_var.dup

2009-01-15 Thread Qian Xu
When shall I use some_var.dup and when not? Is there any guidlines? --Qian

Re: Getting line number where error occured?

2009-01-15 Thread Jarrett Billingsley
On Thu, Jan 15, 2009 at 8:50 PM, Sergey Gromov wrote: > > You're correct, I missed that. Exception is derived from Throwable in > druntime, and Throwable has a field 'info' of type TraceInfo with > opApply in its interface. > > But it doesn't work, at least with DMD 2.023 on Windows. Attempts to

Re: Getting line number where error occured?

2009-01-15 Thread Bill Baxter
On Fri, Jan 16, 2009 at 10:50 AM, Sergey Gromov wrote: > Thu, 15 Jan 2009 13:08:35 -0500, Kagamin wrote: > >> Bill Baxter Wrote: >> >>> Nothing built-in for this, >>> but there are the backtrace hacks: >>> http://team0xf.com/index.php?n=Site.Download >>> Never tried those myself though. >>> >>> I

Re: Getting line number where error occured?

2009-01-15 Thread Sergey Gromov
Thu, 15 Jan 2009 13:08:35 -0500, Kagamin wrote: > Bill Baxter Wrote: > >> Nothing built-in for this, >> but there are the backtrace hacks: >> http://team0xf.com/index.php?n=Site.Download >> Never tried those myself though. >> >> I use a debugger when I need a stack trace. >> http://ddbg.mainia.

Re: using a typedefed variable with library classes

2009-01-15 Thread Christopher Wright
Charles Hixson wrote: A) Yes, it works the way that you say. This damages it's utility. B) I'm replying to a question as to how typedef could reasonably be extended. The point of a typedef is to provide additional type safety. This would not exist if you could implicitly cast back and forth.

Re: easy way to output a struct?

2009-01-15 Thread Jarrett Billingsley
On Thu, Jan 15, 2009 at 6:57 PM, Hoenir wrote: > Why is that "is" used here: > static if(is(a == char*)) > > I know is is normally used for identity comparison, but what does it do > here? is(blah blah) is a completely different thing than "x is y" ;) is() is used to test, at compile time, for s

Re: easy way to output a struct?

2009-01-15 Thread Hoenir
BCS schrieb: I have a partial solution here: http://www.dsource.org/projects/scrapple/browser/trunk/log_api/LogAPI.d Feel free to steal whatever you want from it. If you are really adventures and want to, I can get you SVN access and you can dump stuff back into that. Why is that "is" us

Re: easy way to output a struct?

2009-01-15 Thread Hoenir
bearophile schrieb: Hoenir: So it needs to be recursive somehow. The stuff I have linked you is recursive, of course. Thanks. That's a whole lot of stuff. Guess I really need to dig deeper into template stuff.

Re: easy way to output a struct?

2009-01-15 Thread Hoenir
BCS schrieb: Reply to Hoenir, Denis Koroskin schrieb: One note is that you should probably pass the object by reference: void log(T)(ref T obj) { ... }// D1 void log(T)(ref const(T) obj) { ... } // D2 Good idea. btw ref'ing a class has no effect, has it? ref object would allow yo

Re: easy way to output a struct?

2009-01-15 Thread bearophile
Hoenir: > So it needs to be recursive somehow. The stuff I have linked you is recursive, of course. Bye, bearophile

Re: easy way to output a struct?

2009-01-15 Thread BCS
Reply to Hoenir, Denis Koroskin schrieb: One note is that you should probably pass the object by reference: void log(T)(ref T obj) { ... }// D1 void log(T)(ref const(T) obj) { ... } // D2 Good idea. btw ref'ing a class has no effect, has it? ref object would allow you to alter wha

Re: easy way to output a struct?

2009-01-15 Thread Hoenir
Denis Koroskin schrieb: One note is that you should probably pass the object by reference: void log(T)(ref T obj) { ... }// D1 void log(T)(ref const(T) obj) { ... } // D2 Good idea. btw ref'ing a class has no effect, has it? Actually discovered a flaw, if you e.g. pass an array of st

Re: Getting line number where error occured?

2009-01-15 Thread Kagamin
Bill Baxter Wrote: > Nothing built-in for this, > but there are the backtrace hacks: > http://team0xf.com/index.php?n=Site.Download > Never tried those myself though. > > I use a debugger when I need a stack trace. > http://ddbg.mainia.de/releases.html (Windows - on Linux I think you > can use G

Re: Questions regarding D

2009-01-15 Thread Jarrett Billingsley
On Thu, Jan 15, 2009 at 3:58 AM, Denis Koroskin <2kor...@gmail.com> wrote: > > DX10 headers have been ported long ago: > http://dsource.org/projects/bindings/browser/trunk/win32/directx > Well awesome!

Re: How do I match a dash with munch?

2009-01-15 Thread Simen Kjaeraas
On Thu, 15 Jan 2009 15:30:51 +0100, Jarrett Billingsley wrote: On Thu, Jan 15, 2009 at 8:55 AM, Simen Kjaeraas wrote: munch("bar-baz", "-"); returns "". Is there a way to do this apart from writing my own function? I think you've got the behavior of munch backwards. It will eat any c

Re: How do I match a dash with munch?

2009-01-15 Thread Jarrett Billingsley
On Thu, Jan 15, 2009 at 8:55 AM, Simen Kjaeraas wrote: > munch("bar-baz", "-"); > > returns "". Is there a way to do this apart from writing my own function? I think you've got the behavior of munch backwards. It will eat any characters that _are_ in the pattern string. Since 'b' is not in the

How do I match a dash with munch?

2009-01-15 Thread Simen Kjaeraas
munch("bar-baz", "-"); returns "". Is there a way to do this apart from writing my own function? -- Simen

Re: easy way to output a struct?

2009-01-15 Thread bearophile
Jarrett Billingsley: > bearophile has apparently done so in his "libs" but I have no idea > where you can download that. If you use Phobos on D1 the d.string.put/putr to print generic structs, or use a d.templates.Record struct: http://www.fantascienza.net/leonardo/so/libs_d.zip Bye, bearophile

Re: Questions regarding D

2009-01-15 Thread Bill Baxter
On Thu, Jan 15, 2009 at 5:58 PM, Denis Koroskin <2kor...@gmail.com> wrote: > On Thu, 15 Jan 2009 00:17:30 +0300, Jarrett Billingsley > wrote: > >> On Wed, Jan 14, 2009 at 2:58 PM, William Newbery >> wrote: >> >>> 4)Support for directX: Specificaly I need to be able to use d3d9, d3dx9, >>> d3d10,

Re: easy way to output a struct?

2009-01-15 Thread Denis Koroskin
On Thu, 15 Jan 2009 03:04:15 +0300, Hoenir wrote: BCS schrieb: http://codepad.org/Eu16XqFu Thank you very much, it works like a charm. I wrote a small function to log whatever object I pass to it: void log(T)(T obj) { static if (is(T == struct) || is(T == class)) {

Re: Questions regarding D

2009-01-15 Thread Denis Koroskin
On Wed, 14 Jan 2009 22:58:55 +0300, William Newbery wrote: I use c++ extensivly, however I find several shortcoming of c++ highly annoying, and it looks as if D addresses most of these problems for me, however I'm not certain on certain points as Ive either been unable to find any good in

Re: Questions regarding D

2009-01-15 Thread Denis Koroskin
On Thu, 15 Jan 2009 00:17:30 +0300, Jarrett Billingsley wrote: On Wed, Jan 14, 2009 at 2:58 PM, William Newbery wrote: 4)Support for directX: Specificaly I need to be able to use d3d9, d3dx9, d3d10, d3dx10 and xAudio2. It's entirely possible. D natively supports COM interfaces and th

Re: Questions regarding D

2009-01-15 Thread William Newbery
Jarrett Billingsley Wrote: > On Wed, Jan 14, 2009 at 5:35 PM, William Newbery > wrote: > >> You do have options. DDL is a project which aims to perform dynamic > >> linking on Windows, and it works damn well. It also has a lot of > >> useful utility functions to i.e. look up symbols and types