Re: Template string literal?

2011-03-16 Thread Denis Koroskin
On Thu, 17 Mar 2011 00:30:17 +0300, Jacob Carlborg d...@me.com wrote: Is it possible to declare string literal of a template type, something like this: void bar (const(T)[] a) {} void foo (T) (const(T)[] a) { bar(abcT); } foo(defw); In this case the string literal passed to bar would

Re: Some weird crashes

2011-03-02 Thread Denis Koroskin
On Tue, 01 Mar 2011 23:01:21 +0300, simendsjo simen.end...@pandavre.com wrote: On 28.02.2011 20:24, Denis Koroskin wrote: On Mon, 28 Feb 2011 22:04:44 +0300, simendsjo simen.end...@pandavre.com wrote: On 28.02.2011 18:52, simendsjo wrote: // ERROR auto res = mysql_library_init(0, null

Re: string vs. w/char*

2011-02-28 Thread Denis Koroskin
On Mon, 28 Feb 2011 19:35:47 +0300, Tyro[a.c.edwards] nos...@home.com wrote: On 2/28/2011 11:08 PM, J Chapman wrote: == Quote from Tyro[a.c.edwards] (nos...@home.com)'s article Both implementations results in error code 1812 being returned from GetLastError. explanation of the code reads:

Re: How-to manipulate a C array with D2 vector operations?

2011-02-28 Thread Denis Koroskin
On Mon, 28 Feb 2011 19:51:28 +0300, Lars Holowko lars.holo...@gmail.com wrote: Hi I am trying to implement a D2 function that has this C signature (it gets called from a C module and I cannot change the caller): extern(C) read_into(char *buffer, size_t buf_len); I would like to use D's

Re: Some weird crashes

2011-02-28 Thread Denis Koroskin
On Mon, 28 Feb 2011 22:04:44 +0300, simendsjo simen.end...@pandavre.com wrote: On 28.02.2011 18:52, simendsjo wrote: // ERROR auto res = mysql_library_init(0, null, null); auto cn = mysql_init(null); auto oldcn = cn; writeln(mysql_errno(cn)); assert(cn == oldcn); // when the last assert

Re: string vs. w/char*

2011-02-28 Thread Denis Koroskin
On Tue, 01 Mar 2011 02:08:48 +0300, Tyro[a.c.edwards] nos...@home.com wrote: == Quote from Denis Koroskin (2kor...@gmail.com)'s article On Mon, 28 Feb 2011 19:35:47 +0300, Tyro[a.c.edwards] nos...@home.com wrote: On 2/28/2011 11:08 PM, J Chapman wrote: == Quote from Tyro[a.c.edwards

Re: What is -nofloat good for?

2011-02-24 Thread Denis Koroskin
On Thu, 24 Feb 2011 16:29:03 +0300, Lars T. Kyllingstad public@kyllingen.nospamnet wrote: The dmd help text says the following about the -nofloat switch: -nofloat do not emit reference to floating point What does this mean? What is -nofloat good for? -Lars Software floating point

Re: OpenGL in D2

2011-02-21 Thread Denis Koroskin
On Mon, 21 Feb 2011 14:45:51 +0300, Dmitry Olshansky dmitry.o...@gmail.com wrote: On 21.02.2011 13:33, Siqu wrote: Hi, I'm trying to figure out how I could get a simple OpenGL/GLUT program working in DMD2. As an attachment, I've added a C version of what I'd like to do. I'd compile the

Re: Isn't using find with retro awkward?

2011-02-15 Thread Denis Koroskin
On Tue, 15 Feb 2011 06:35:21 +0300, Andrej Mitrovic n...@none.none wrote: import std.stdio, std.algorithm, std.range; void main() { writeln( find([5, 1, 2, 3, 4, 5, 1], 5) ); writeln( find(retro([5, 1, 2, 3, 4, 5, 1]), 5) ); } Output: [5, 1, 2, 3, 4, 5, 1] [5, 4, 3, 2, 1, 5] The docs

Re: Isn't using find with retro awkward?

2011-02-15 Thread Denis Koroskin
On Wed, 16 Feb 2011 09:22:02 +0300, Denis Koroskin 2kor...@gmail.com wrote: On Tue, 15 Feb 2011 06:35:21 +0300, Andrej Mitrovic n...@none.none wrote: import std.stdio, std.algorithm, std.range; void main() { writeln( find([5, 1, 2, 3, 4, 5, 1], 5) ); writeln( find(retro([5, 1, 2

Re: Asynchronous concurrency with reference types

2011-02-05 Thread Denis Koroskin
On Sat, 05 Feb 2011 20:42:53 +0300, Peter Alexander peter.alexander...@gmail.com wrote: On 5/02/11 12:11 AM, Sean Kelly wrote: Peter Alexander Wrote: Things might be easier if the error messages associated with D's concurrent features weren't especially unhelpful (for example, trying to

Re: Classes or stucts :: Newbie

2010-12-19 Thread Denis Koroskin
On Mon, 20 Dec 2010 18:00:31 +0300, David Currie curri...@iinet.net.au wrote: I am new to D (like many have done C++ , Java ). Can a class be instantiated on the stack ? eg class C { private int _I1; private int _I2; public: this(int pI) // constructor { _I1 = pI;

Re: Classes or stucts :: Newbie

2010-12-19 Thread Denis Koroskin
On Mon, 20 Dec 2010 18:00:31 +0300, David Currie curri...@iinet.net.au wrote: I am new to D (like many have done C++ , Java ). Can a class be instantiated on the stack ? eg class C { private int _I1; private int _I2; public: this(int pI) // constructor { _I1 = pI;

Re: string comparison

2010-12-19 Thread Denis Koroskin
Check your client setting, everything is perfect on my side (Opera built-in news client).

Re: Cannot find symbol using wine

2010-10-25 Thread Denis Koroskin
On Mon, 25 Oct 2010 07:33:40 +0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Sunday 24 October 2010 18:20:53 Denis Koroskin wrote: On Mon, 25 Oct 2010 05:03:50 +0400, Jonathan M Davis jmdavisp...@gmx.com wrote: I'm trying to read from the registry (thus far unsuccesfully

Re: exception types objects

2010-10-19 Thread Denis Koroskin
On Tue, 19 Oct 2010 22:54:33 +0400, Kagamin s...@here.lot wrote: spir Wrote: The example uses an Excpetion type, but the somewhat comment contradicts it. Can one really use any kind of object as exception? ps it's fun to throw strings in javascript, try it. :3 I've been throwing const

Re: Replacement for C++ Style Implicit casts?

2010-10-18 Thread Denis Koroskin
On Mon, 18 Oct 2010 23:47:40 +0400, Mike Chaten mcha...@gmail.com wrote: In C++ it is possible to declare a class as follows class Foo { Foo(int x) { } } You can then use that constructor to implicitly convert int to Foo. E.g Foo x = 0; //equivalent to Foo(0) Is there a way in D to do an

Re: Anyone using Portaudio?

2010-10-17 Thread Denis Koroskin
On Mon, 18 Oct 2010 01:10:31 +0400, Andrej Mitrovic andrej.mitrov...@none.com wrote: There's a .d header file in the Bindings project on dsource which I'm using with the Portaudio DLL v19, and I'm implicitly loading the DLL. There's a sine playback example, and I'm comparing the usage of

Re: Anyone using Portaudio?

2010-10-17 Thread Denis Koroskin
On Mon, 18 Oct 2010 04:16:10 +0400, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Here's the update, I hope someone puts it in the repo: http://www.dsource.org/forums/viewtopic.php?p=25726#25726 IIRC, the repo is public, i.e. everyone has commit access. If so, you can commit the

Re: Calling D function from C

2010-10-12 Thread Denis Koroskin
On Tue, 12 Oct 2010 08:10:31 +0400, Daniel Worthington daniel.worthing...@gmail.com wrote: Linking with the phobos lib got it to compile, but I get a Bus Error when running: EXC_BAD_ACCESS (SIGBUS). Playing with the code a bit and looking at the crash reports, it looks like this happens

Re: Calling D function from C

2010-10-12 Thread Denis Koroskin
On Tue, 12 Oct 2010 11:46:39 +0400, Emil Madsen sove...@gmail.com wrote: wouldn't compiling, without garbage collector help too? 2010/10/12 Denis Koroskin 2kor...@gmail.com On Tue, 12 Oct 2010 08:10:31 +0400, Daniel Worthington daniel.worthing...@gmail.com wrote: Linking with the phobos

Re: mutable reference to const object

2010-10-12 Thread Denis Koroskin
On Tue, 12 Oct 2010 13:07:59 +0400, Benjamin Thaut c...@benjamin-thaut.de wrote: I want to have a mutable reference to a const object. So that I can reasign the reference but can not modifiy the object. Is this possible in D 2.0? I found tailconst in the const FAQ but as it is not

Re: A question about DbC

2010-10-09 Thread Denis Koroskin
On Sat, 09 Oct 2010 07:16:10 +0400, bearophile bearophileh...@lycos.com wrote: This is a simple D2 class that uses Contracts: import std.c.stdio: printf; class Car { int speed = 0; invariant() { printf(Car invariant: %d\n, speed); assert(speed = 0); }

Re: A question about DbC

2010-10-09 Thread Denis Koroskin
On Sat, 09 Oct 2010 14:20:18 +0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Saturday 09 October 2010 03:09:30 Denis Koroskin wrote: Given that pre-, post-conditions and invariants are all pure, it doesn't really matter in what order they are executed. In effect yes, but they aren't

Re: A question about DbC

2010-10-09 Thread Denis Koroskin
On Sat, 09 Oct 2010 14:44:41 +0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Saturday 09 October 2010 03:25:48 Denis Koroskin wrote: Well, I meant they are conceptually pure. Yes, they are conceptually pure, just not actually pure. But do believe you shouldn't be able to use writeln

Re: A question about DbC

2010-10-09 Thread Denis Koroskin
On Sat, 09 Oct 2010 15:06:40 +0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Saturday 09 October 2010 03:47:52 Denis Koroskin wrote: Why not just throw an exception and get a nice stack trace? You get a stack trace anyway with an assertion failure. And sure, they _could_ make it so

Re: A question about DbC

2010-10-09 Thread Denis Koroskin
On Sat, 09 Oct 2010 15:32:26 +0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Saturday 09 October 2010 04:23:25 Denis Koroskin wrote: On Sat, 09 Oct 2010 15:06:40 +0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Saturday 09 October 2010 03:47:52 Denis Koroskin wrote: Why

Re: question about property for built-in type

2010-10-08 Thread Denis Koroskin
On Fri, 08 Oct 2010 16:19:43 +0400, %u djvsr...@gmail.com wrote: Hi, I'm learning D right now and got a question about property. I tried to add a property for built-in type like the following @property bool equalZero(double a) { return a == 0.0; } void main() { ... double x = 4.4; bool

Re: [D1][expressions] Order Of Evaluation

2010-10-08 Thread Denis Koroskin
On Fri, 08 Oct 2010 18:49:36 +0400, %u e...@ee.com wrote: /The following binary expressions are evaluated in an implementation-defined order: AssignExpression/../AddExpression/ /It is an error to depend on order of evaluation when it is not specified./ That makes this an error!? y = x +

Re: ditto in DDoc

2010-10-08 Thread Denis Koroskin
On Sat, 09 Oct 2010 01:22:33 +0400, Tomek Sowiński j...@ask.me wrote: More of an English question... dunno - don't know ditto - ? Ditto is used to indicate that something already said is applicable a second time. In documentation, ditto means that previous comment also applies here. Here

Re: write to file ... trivial?

2010-10-07 Thread Denis Koroskin
On Thu, 07 Oct 2010 01:36:23 +0400, Dr. Smith i...@far.out wrote: Thank you. Indeed, I forgot: auto f = File(outfile.txt, w); Interestingly, this apparently works within a for-loop to overwrite the file on the first iteration and appending otherwise (Should there not be an explicit

Re: class x is hidden by y

2010-10-07 Thread Denis Koroskin
On Thu, 07 Oct 2010 10:43:12 +0400, Benjamin Thaut c...@benjamin-thaut.de wrote: For the following code in D 2.0 using dmd 2.049: import std.stdio; abstract class foo { protected: void WrongType(){ assert(0,Using wrong type); } public: void Update(int

Re: Initialisation of static immutable arrays

2010-10-06 Thread Denis Koroskin
On Wed, 06 Oct 2010 15:39:48 +0400, Steven Schveighoffer schvei...@yahoo.com wrote: BTW, I'm all for making array literals immutable. You can always make runtime-allocated arrays via a library function. -Steve I second that!

Re: Initialisation of static immutable arrays

2010-10-06 Thread Denis Koroskin
On Wed, 06 Oct 2010 16:21:08 +0400, Lars T. Kyllingstad pub...@kyllingen.nospamnet wrote: On Wed, 06 Oct 2010 07:39:48 -0400, Steven Schveighoffer wrote: On Wed, 06 Oct 2010 06:16:45 -0400, Lars T. Kyllingstad pub...@kyllingen.nospamnet wrote: [...] Secondly, if the above is not true,

Re: Using the llvm D-bindings

2010-10-06 Thread Denis Koroskin
On Wed, 06 Oct 2010 16:20:41 +0400, Manuel König manuel...@gmx.net wrote: Hi, did anyone have success using the llvm-2.7 D-bindings from the bindings project http://www.dsource.org/projects/bindings on x86_64 linux? I tried so far with ldc, but the compiler chokes about a mere 3570 lines of

Re: write to file ... trivial?

2010-10-06 Thread Denis Koroskin
On Wed, 06 Oct 2010 22:43:42 +0400, Dr. Smith i...@far.out wrote: This should be trivial. However, I've not found in the documentation (trying both std.stdio and std.file) how to write to a file in the manner here: filename.writefln(%s\t%f, someString, someDouble); ... this merely prints

Re: Associative arrays give compile error

2010-10-05 Thread Denis Koroskin
On Tue, 05 Oct 2010 14:23:47 +0400, Bob Cowdery b...@bobcowdery.plus.com wrote: I can't seem to get any sense out of associative arrays. Even the simplest definition won't compile so I must be doing something daft. int[string] aa = [hello:42]; Error: non-constant expression [hello:42]

Re: Associative arrays give compile error

2010-10-05 Thread Denis Koroskin
On Tue, 05 Oct 2010 14:57:22 +0400, Bob Cowdery b...@bobcowdery.plus.com wrote: On 05/10/2010 11:45, Denis Koroskin wrote: On Tue, 05 Oct 2010 14:23:47 +0400, Bob Cowdery b...@bobcowdery.plus.com wrote: I can't seem to get any sense out of associative arrays. Even the simplest definition

Re: Associative arrays give compile error

2010-10-05 Thread Denis Koroskin
On Tue, 05 Oct 2010 15:08:39 +0400, Bob Cowdery b...@bobcowdery.plus.com wrote: On 05/10/2010 12:04, Denis Koroskin wrote: On Tue, 05 Oct 2010 14:57:22 +0400, Bob Cowdery b...@bobcowdery.plus.com wrote: On 05/10/2010 11:45, Denis Koroskin wrote: On Tue, 05 Oct 2010 14:23:47 +0400, Bob

Re: Associative arrays give compile error

2010-10-05 Thread Denis Koroskin
On Tue, 05 Oct 2010 15:40:39 +0400, Bob Cowdery b...@bobcowdery.plus.com wrote: On 05/10/2010 12:13, Denis Koroskin wrote: On Tue, 05 Oct 2010 15:08:39 +0400, Bob Cowdery b...@bobcowdery.plus.com wrote: On 05/10/2010 12:04, Denis Koroskin wrote: On Tue, 05 Oct 2010 14:57:22 +0400, Bob

Re: Associative arrays give compile error

2010-10-05 Thread Denis Koroskin
On Tue, 05 Oct 2010 15:50:44 +0400, Bob Cowdery b...@bobcowdery.plus.com wrote: On 05/10/2010 12:40, Bob Cowdery wrote: On 05/10/2010 12:13, Denis Koroskin wrote: On Tue, 05 Oct 2010 15:08:39 +0400, Bob Cowdery b...@bobcowdery.plus.com wrote: On 05/10/2010 12:04, Denis Koroskin wrote

Re: Associative arrays give compile error

2010-10-05 Thread Denis Koroskin
On Tue, 05 Oct 2010 15:53:55 +0400, Denis Koroskin 2kor...@gmail.com wrote: On Tue, 05 Oct 2010 15:40:39 +0400, Bob Cowdery b...@bobcowdery.plus.com wrote: On 05/10/2010 12:13, Denis Koroskin wrote: On Tue, 05 Oct 2010 15:08:39 +0400, Bob Cowdery b...@bobcowdery.plus.com wrote: On 05

Re: Associative arrays give compile error

2010-10-05 Thread Denis Koroskin
On Tue, 05 Oct 2010 16:32:14 +0400, Bob Cowdery b...@bobcowdery.plus.com wrote: On 05/10/2010 13:05, Denis Koroskin wrote: On Tue, 05 Oct 2010 15:53:55 +0400, Denis Koroskin 2kor...@gmail.com wrote: On Tue, 05 Oct 2010 15:40:39 +0400, Bob Cowdery b...@bobcowdery.plus.com wrote: On 05

Re: Associative arrays give compile error

2010-10-05 Thread Denis Koroskin
On Tue, 05 Oct 2010 17:00:13 +0400, Bob Cowdery b...@bobcowdery.plus.com wrote: On 05/10/2010 13:45, Denis Koroskin wrote: On Tue, 05 Oct 2010 16:32:14 +0400, Bob Cowdery b...@bobcowdery.plus.com wrote: On 05/10/2010 13:05, Denis Koroskin wrote: On Tue, 05 Oct 2010 15:53:55 +0400, Denis

Re: Associative arrays give compile error

2010-10-05 Thread Denis Koroskin
On Wed, 06 Oct 2010 03:45:11 +0400, bearophile bearophileh...@lycos.com wrote: /*immutable*/ E_MODE[string] a_mode; static this () { foreach (m; __traits(allMembers, E_MODE)) mixin(`a_mode[` ~ m ~ `] = E_MODE.` ~ m ~ `;`); } How do you build an immutable AA that is global or

Re: Associative arrays give compile error

2010-10-05 Thread Denis Koroskin
On Wed, 06 Oct 2010 04:14:37 +0400, bearophile bearophileh...@lycos.com wrote: Denis Koroskin: I found the following to work fine: K[V] assocArray = createAssocArray(); K[V] createAssocArray() { K[V] assocArray = [ k1: v1, k2: v2, ... ]; return

Re: linked list

2010-09-27 Thread Denis Koroskin
On Mon, 27 Sep 2010 10:27:36 +0400, Joel Christensen joel...@gmail.com wrote: Thanks for the long winded reply Jonathan. I don't know how to avoid using my own linked list, I have next/prev in each class (Ball, Lazer and Mine ) in the list. That's called intrusive linked list, and I

Re: Should be easy

2009-06-12 Thread Denis Koroskin
On Sat, 13 Jun 2009 03:37:59 +0400, Saaa em...@needmail.com wrote: IndexArray should take an array of integers as well. The int[] foo... syntax is implicit convert to array anyway. I think I'll go with Christophers code, hope you don't mind :) Also, please bottom-post. It's the

Re: Who wants to have some fun memory debugging?

2009-05-13 Thread Denis Koroskin
On Wed, 13 May 2009 10:48:53 +0400, grauzone n...@example.net wrote: Maybe it's time to put together an instrumented GC... Wishlist: - some way to know _when_ a collection happened (or how often) - logging of allocations (module/linenumber of allocator, size of allocation, type of

Re: Need direction guide

2009-05-04 Thread Denis Koroskin
On Mon, 04 May 2009 12:29:54 +0400, Sam Hu samhudotsa...@gmail.com wrote: I have learnt C++ for years and can write simple and short toys.I have been following and learning D for quite a while but I can do nothing except finding ppl like you giant seems just write libs at this moment.I

Re: SQLite with D

2009-04-24 Thread Denis Koroskin
On Fri, 24 Apr 2009 06:44:56 +0400, reimi gibbons re...@hotmail.com wrote: im failry new to D, is there any D library project with support for SQLite, if not is there any guide so i can integrate sqlite amalgamated c source (sqlite3.c, sqlite3.h) into my D code. There is a DDBI project

Re: Stack allocator?

2009-04-19 Thread Denis Koroskin
On Sun, 19 Apr 2009 10:15:41 +0400, Tim Matthews tim.matthe...@gmail.com wrote: On Sat, 18 Apr 2009 16:42:28 -0700 Robert Fraser fraseroftheni...@gmail.com wrote: I remember a while back someone posted an easy dynamic stack allocator... anyone have the link? Thanks, Robert Tango has this:

Re: problem with gdc for OSX?

2009-04-19 Thread Denis Koroskin
On Sun, 19 Apr 2009 12:37:11 +0400, MLT n...@anon.com wrote: Sorry, this could be a bug report and not a question, and probably the wrong place to post it then. I installed gdc according to the instructions given in http://www.dsource.org/projects/tango/wiki/MacOSXInstall from

Re: Widening a type

2009-04-17 Thread Denis Koroskin
On Fri, 17 Apr 2009 06:11:00 +0400, Doctor J nob...@nowhere.com wrote: OK, here's one for you that sounds like it ought to be easy, but I don't immediately see how to do it in a pretty way. Given a type parameter T of a template: If T is an integral type, I want to declare a variable

Re: Encapsulation Win32 SDK with class in DMD2028 problem--Help wanted

2009-04-17 Thread Denis Koroskin
On Fri, 17 Apr 2009 13:22:21 +0400, Sam Hu samhudotsa...@gmail.com wrote: Forget attachment.Resent. Sam Hu Wrote: Hello, After my reading below post: http://d.puremagic.com/issues/show_bug.cgi?id=2580 I can compile the win32 SDK sample in dmd\sample folder.After that I tried to

Re: Template classes

2009-04-14 Thread Denis Koroskin
On Wed, 15 Apr 2009 01:01:28 +0400, Andrew Spott andrew.sp...@gmail.com wrote: So, the attached is supposed to be a class that creates a vector of any type (I would like it to only take numerical values (int, float, real, double, etc), however, I am ok with it taking others (not that I see

Re: wchar[] and wchar*

2009-04-07 Thread Denis Koroskin
(I wonder why this message wasn't sent hours ago and stuck in my mailbox, but here it goes:) On Tue, 07 Apr 2009 09:32:59 +0400, novice2 so...@noem.ail wrote: hi! could you advice me, please, what techniques should be used while working with D wchar[] and C wchar* (e.g. Windows unicode API

Re: Can somebody explain this memory usage

2009-04-02 Thread Denis Koroskin
On Thu, 02 Apr 2009 10:08:52 +0400, Saaa em...@needmail.com wrote: I forgot to mention it is about a program I made :D (not the compiler itself or something) I belive you have a bug in line 42. dmd 1.042 Phobos OpenGl + SDL (Derelict) mem usage (winxp task manager) = 60MB, peak = 120MB

Re: Sockets and D?

2009-04-02 Thread Denis Koroskin
On Fri, 03 Apr 2009 04:19:10 +0400, Jimi_Hendrix myspo...@gmail.com wrote: Hi, I am new to D but not to programming. I have had some socket experience before. How would i connect to a server using sockets in D? A link to a D socket tutorial (if one exists) would also be appreciated. by

Re: Sockets and D?

2009-04-02 Thread Denis Koroskin
On Fri, 03 Apr 2009 04:55:59 +0400, jimi hendrix myspo...@gmail.com wrote: On Fri, 03 Apr 2009 04:35:21 +0400, Denis Koroskin wrote: I'd suggest you to look at Tango as it has very impressive networking feature set. tutorial? also what do i need to download to use tango? http

Re: mixing array and string .find()

2009-03-23 Thread Denis Koroskin
Try the following: int find(T)(T[] array, T obj) if (!is(T : char)) { foreach (i, v; array) { if (v == obj) return i; } return -1; }

Re: lvalue - opIndexAssign - Tango

2009-03-13 Thread Denis Koroskin
On Sat, 14 Mar 2009 06:41:52 +0300, The Anh Tran trthe...@gmail.com wrote: Hi, When porting from c++ to D, i encounter this strange discrimination: 1. Built-in AA: int[int] arr; arr[123] += 12345; arr[321]++; 2. Tango HashMap: auto hm = new HashMap!(int,

Re: # operator under C implementation in D1

2009-03-12 Thread Denis Koroskin
On Fri, 13 Mar 2009 04:19:11 +0300, Sam Hu samhu.sa...@gmail.com wrote: I know a little that in C there is a # operator which under a macro can return any type's value in character format.Just wanna know whether there is an equivelent implementation in D1.Say,in C using a/m macro can

Re: Newbie question: COM programming and linking to Windows libraries

2009-03-11 Thread Denis Koroskin
On Thu, 12 Mar 2009 00:31:33 +0300, Patrick Kristiansen patrick.kristian...@gmail.com wrote: Hi I've been trying out D lately, and I really love it. I use the Tango library at the moment, and I wanted to do some simple COM programming, which I'm also a newbie at, just to get more

Re: Char[] confusing

2009-03-02 Thread Denis Koroskin
On Tue, 03 Mar 2009 02:03:23 +0300, BCS a...@pathlink.com wrote: Reply to Qian, Hi, I am confusing with getting sub-string of a char[]. [..] My question is: why s[4]=E, but s[0..4]=ABCD (without E) Having the fist number be included and the second not works better than the other

Re: Any way to track memory allocations?

2009-02-24 Thread Denis Koroskin
On Tue, 24 Feb 2009 20:40:13 +0300, BCS a...@pathlink.com wrote: Reply to Jarrett, Hm, actually.. If you *are* using D2, you might be able to replace the GC interface with a debug interface that just forwards calls to the normal GC. This is a capability druntime inherited from the Tango

Re: Can i safely cast void* from void[]?

2009-02-08 Thread Denis Koroskin
On Mon, 09 Feb 2009 00:25:41 +0300, Heinz malagan...@yahoo.es wrote: Hi, I remember i read around the D site that dinamic arrays can be stored in system memory in a 'non contiguous' way (different locations). I was trying to find again that page but haven't had any lucky. I'm not crazy,

Re: Deleting an element from an array

2009-02-03 Thread Denis Koroskin
On Tue, 03 Feb 2009 15:46:52 +0300, nobody someb...@somewhere.com wrote: What is the best way to completely remove an element from an array? For example you have an array: [1,2,3,4,5,6] and want to remove element 3 in such a way that the resulting array is: [1,2,4,5,6] Thanks. import

Re: Is there a way to remove the requirement for parenthesis?

2009-01-28 Thread Denis Koroskin
On Wed, 28 Jan 2009 08:45:12 +0300, Daniel Keep daniel.keep.li...@gmail.com wrote: Honestly, I can't see what you're trying to accomplish. It looks like you want something that's not called int, but which works exactly like an int does, and can be passed as one. If you just want another

Re: Prevent default-initialised struct

2009-01-26 Thread Denis Koroskin
On Mon, 26 Jan 2009 20:40:01 +0300, BCS n...@anon.com wrote: Hello Daniel, Hi all, is there any way to prevent a struct from being created directly? Basically, I want to prevent this: { non_null!(T) a; } I want people to have to use provided functions to create a structure: { auto a =

Re: long compile time 2.023 (few lines of code)

2009-01-26 Thread Denis Koroskin
On Tue, 27 Jan 2009 01:08:17 +0300, Saaa em...@needmail.com wrote: Should I report this as a bug? And, how do I do that :) Lol I didn't even check that. Probably because it does compile (and gives a stack overflow at runtime) when you put the allocation within the main. So it still looks

Re: Class and Interface Fun

2009-01-25 Thread Denis Koroskin
On Sun, 25 Jan 2009 08:38:18 +0300, Tim M a...@b.com wrote: On Sun, 25 Jan 2009 17:56:03 +1300, John Reimer terminal.n...@gmail.com wrote: Hello tim, On Sun, 25 Jan 2009 16:43:55 +1300, John Reimer terminal.n...@gmail.com wrote: With this code: module

Re: Class and Interface Fun

2009-01-25 Thread Denis Koroskin
On Sun, 25 Jan 2009 15:06:23 +0300, Tim M a...@b.com wrote: On Mon, 26 Jan 2009 00:48:21 +1300, Tim M a...@b.com wrote: On Mon, 26 Jan 2009 00:18:28 +1300, Denis Koroskin 2kor...@gmail.com wrote: On Sun, 25 Jan 2009 08:38:18 +0300, Tim M a...@b.com wrote: On Sun, 25 Jan 2009 17:56:03

Re: Class and Interface Fun

2009-01-25 Thread Denis Koroskin
On Sun, 25 Jan 2009 15:20:19 +0300, Tim M a...@b.com wrote: On Mon, 26 Jan 2009 01:14:10 +1300, Denis Koroskin 2kor...@gmail.com wrote: On Sun, 25 Jan 2009 15:06:23 +0300, Tim M a...@b.com wrote: On Mon, 26 Jan 2009 00:48:21 +1300, Tim M a...@b.com wrote: On Mon, 26 Jan 2009 00:18:28

Re: Class and Interface Fun

2009-01-25 Thread Denis Koroskin
On Sun, 25 Jan 2009 17:06:50 +0300, Denis Koroskin 2kor...@gmail.com wrote: On Sun, 25 Jan 2009 15:20:19 +0300, Tim M a...@b.com wrote: On Mon, 26 Jan 2009 01:14:10 +1300, Denis Koroskin 2kor...@gmail.com wrote: On Sun, 25 Jan 2009 15:06:23 +0300, Tim M a...@b.com wrote: On Mon, 26 Jan

Re: Why does this work?

2009-01-24 Thread Denis Koroskin
Mike L. Wrote: I saved and compiled the code given as getenv.d on the page http://www.digitalmars.com/d/archives/digitalmars/D/learn/623.html but I'm not entirely sure why it works. The reasons that I don't understand it are: 1. GetEnvironmentStringsA() and the other functions aren't

Re: long compile time 2.023 (few lines of code)

2009-01-23 Thread Denis Koroskin
Saaa Wrote: The following code takes too long to compile (I kill link.exe to stop it) dmd 2.023 bud -full - cleanup -- module project.main; import project.bug; void main() { } -- module project.bug; struct Struct { uint number; int[6] array; byte[9] array2; } Struct

Re: How to get the implementer of an interface?

2009-01-22 Thread Denis Koroskin
On Thu, 22 Jan 2009 11:17:20 +0300, Qian Xu quian...@stud.tu-ilmenau.de wrote: Hello All, how to get the implementer of an interface? Here is an example: - interface intf_1 {} class c_1 : intf_1 {} class c_2 : c_1 {} c_1 aaa = new

Re: Is there a way to remove the requirement for parenthesis?

2009-01-21 Thread Denis Koroskin
On Wed, 21 Jan 2009 20:26:08 +0300, Charles Hixson charleshi...@earthlink.net wrote: P.S.: This is Digital Mars D Compiler v2.023 running on Linux Charles Hixson wrote: In this test I'm trying to emulate how I want a typedef to act, but I run into a problem: import std.stdio; struct

Re: main return value, struct padding

2009-01-20 Thread Denis Koroskin
Jarrett Billingsley Wrote: On Tue, Jan 20, 2009 at 12:21 PM, Steven Schveighoffer schvei...@yahoo.com wrote: So it appears it returns 0 unless you return something else (!) Ha! Yes (but not always), even though specs clearly say that void functions evaluate return values and discard

Re: confused with some_var.dup

2009-01-16 Thread Denis Koroskin
On Fri, 16 Jan 2009 10:30:53 +0300, Qian Xu quian...@stud.tu-ilmenau.de wrote: When shall I use some_var.dup and when not? Is there any guidlines? --Qiansua .dup is typical way to makes a copy of variable: char[] greetings = Hello, World!.dup; You usually do this when you want to modify

Re: Questions regarding D

2009-01-15 Thread Denis Koroskin
On Wed, 14 Jan 2009 22:58:55 +0300, William Newbery wnewb...@hotmail.co.uk 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

Re: easy way to output a struct?

2009-01-15 Thread Denis Koroskin
On Thu, 15 Jan 2009 03:04:15 +0300, Hoenir mrmoc...@gmx.de 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: Foreach problem

2009-01-10 Thread Denis Koroskin
On Sun, 11 Jan 2009 06:04:01 +0300, Tim M a...@b.com wrote: On Sun, 11 Jan 2009 15:59:26 +1300, Tim M a...@b.com wrote: On Sun, 11 Jan 2009 15:50:54 +1300, Daniel Keep daniel.keep.li...@gmail.com wrote: Tim M wrote: Why is this an error. Dmd wants to make sure that I declare a new

Re: object splitting in multiple threads

2009-01-09 Thread Denis Koroskin
On Sat, 10 Jan 2009 05:44:20 +0300, yes y...@no.com wrote: How bad is the following idea? class Calc { void addThread() { Data data; data = new Data(); } void run() { if ( hardware threads current threadcount) { addThread(); } //wait for some signal //run calculations on data / threads

Re: question on tuples and expressions

2009-01-05 Thread Denis Koroskin
On Mon, 05 Jan 2009 22:42:30 +0300, Jarrett Billingsley jarrett.billings...@gmail.com wrote: On Mon, Jan 5, 2009 at 2:39 PM, Denis Koroskin 2kor...@gmail.com wrote: Both work for me (dmd 2.012): import std.typecons; void main() { Tuple!(int, int) x = Tuple!(int, int)(1, 2); Tuple!(int

Re: Compile-time reference type objects construction (Was - Re: struct

2008-12-22 Thread Denis Koroskin
Kagamin Wrote: Denis Koroskin Wrote: class Widget { WidgetFactory* factory = defaultFactory; } void main() { Widget w = new Widget(); writefln(w.factory.someParameterValue); // prints 14 } You initialize member field here. It's usually done in instance

Re: plain C to D2 const etc:

2008-12-15 Thread Denis Koroskin
On Mon, 15 Dec 2008 20:11:44 +0300, BLS nan...@nospam.wanadoo.fr wrote: Hi, what is the correct way to translate this snippet into _D2_ ? //const and cast() void rc2_decrypt( const unsigned short xkey[64], unsigned char *plain, const unsigned char *cipher

Re: confusing (buggy?) closure behaviour

2008-12-12 Thread Denis Koroskin
On Fri, 12 Dec 2008 22:28:01 +0300, Zoran Isailovski dmd@spamgourmet.com wrote: Denis Koroskin Wrote: On Fri, 12 Dec 2008 19:32:03 +0300, Zoran Isailovski dmd@spamgourmet.com wrote: I'm an experienced C#, Java and Python programmer, and have employed closures (and C# delegates

Re: Why is my structure template does not compile?

2008-12-11 Thread Denis Koroskin
On Fri, 12 Dec 2008 02:21:11 +0300, BCS a...@pathlink.com wrote: Reply to Weed, ref Element opIndex( in uint n ) { return data[n]; } ref Element opIndexAssign( in Element a, in uint n ) { data[n] += a; return data[n]; } I'm guessing as I don't use 2.0 but I think that this is a bug. DMD

Re: -nan problem???

2008-12-11 Thread Denis Koroskin
On Fri, 12 Dec 2008 02:26:55 +0300, Sheridan superp...@freemai.hu wrote: Hi! I am new in D language. I implement a little 2D/3D engine, and during the development I faced an interesting problem. I have this function: void addBackgroundToLayer2(char[] textureName, float posx, float posy)

Re: Why is my structure template does not compile?

2008-12-11 Thread Denis Koroskin
On Fri, 12 Dec 2008 02:47:42 +0300, BCS a...@pathlink.com wrote: Reply to Denis, On Fri, 12 Dec 2008 02:21:11 +0300, BCS a...@pathlink.com wrote: Reply to Weed, invariant() { // If I comment out next line compilation goes smoothly: assert( Element.sizeof 0 ); } OTOH that assert is

Re: myClass.add(something)(otherthings)(thisToo);

2008-12-10 Thread Denis Koroskin
On Wed, 10 Dec 2008 19:31:47 +0300, BCS [EMAIL PROTECTED] wrote: Reply to Denis, On Wed, 10 Dec 2008 03:24:48 +0300, Jarrett Billingsley [EMAIL PROTECTED] wrote: On Tue, Dec 9, 2008 at 7:00 PM, BCS [EMAIL PROTECTED] wrote: final void add(T...)(T t) If all the params are the same type,

Re: static initialization question

2008-12-10 Thread Denis Koroskin
On Thu, 11 Dec 2008 02:13:58 +0300, Weed [EMAIL PROTECTED] wrote: Denis Koroskin пишет: On Thu, 11 Dec 2008 01:31:32 +0300, Weed [EMAIL PROTECTED] wrote: But my class does not contain data that need initialization and can be created in compile time code: import std.stdio; class MyClass

Re: Cyclic Dependencies

2008-12-09 Thread Denis Koroskin
On Tue, 09 Dec 2008 10:26:29 +0300, Ellery Newcomer [EMAIL PROTECTED] wrote: Also, I would be trying to compile with DMD, but I have evidently managed to crash the compiler, and I don't know if it's DMD's fault or mine. It reports an Internal Error in e2ir.c at line 3904. (not being a C++

Re: myClass.add(something)(otherthings)(thisToo);

2008-12-09 Thread Denis Koroskin
On Wed, 10 Dec 2008 02:40:47 +0300, tsalm [EMAIL PROTECTED] wrote: Hello, How to implement an object that can do this : myClass.add(something)(otherthings)(thisToo); Is it possible ? TIA, TSalm Yes: import std.stdio; class MyClass { class MyClassAdder { MyClassAdder

Re: Safe to throw away function arguments with cast?

2008-12-04 Thread Denis Koroskin
On Thu, 04 Dec 2008 18:37:10 +0300, Brian [EMAIL PROTECTED] wrote: Is it safe to cast a function(or delegate) into one that takes more arguments, causing those arguments to be ignored? Example: void fn() { } auto fptr = cast(void function(int, int))fn; fptr(1, 2); // It seems to work with

Re: Getting environment variables?

2008-11-24 Thread Denis Koroskin
On Mon, 24 Nov 2008 16:53:20 +0300, Christopher Wright [EMAIL PROTECTED] wrote: John C wrote: novice2 Wrote: i am afraid that windows API named *W works with UCS2 string. but D wchar[] is UTF-16. Wrong - Windows has used UTF-16 as native since Windows 2000. Actually, you're both right.

Re: Compilation error when using a extern function ?

2008-11-20 Thread Denis Koroskin
21.11.08 в 01:57 tsalm в своём письме писал(а): Hello, I'm on DMD 1.036. When I'm compiling this code : // -CODE--- enum ColorValues:uint { AliceBlue = 0xF0F8 ,AntiqueWhite = 0xF8ECD8FF ,Aqua = 0x00FF ,Aquamarine = 0x80FFD0FF