Re: Class and Interface Fun

2009-01-25 Thread Christopher Wright
Denis Koroskin wrote: On Sun, 25 Jan 2009 08:38:18 +0300, Tim M a...@b.com wrote: class B : A,I { void foo() { A.foo(); } } void main() { } It is too verbose and makes twice an overhead. I'd like to avoid this solution. Any reasonable compiler would inline the call to A.foo. In

Re: Getting D language patch into GDB

2009-01-24 Thread Christopher Wright
Jason House wrote: I was chatting on #gdb earlier today and it sounds like getting a patch for the d programming language into gdb shouldn't be too bad. There's a patches mailing list and some kind of paperwork to resolve copyright issues. Is there any legal/copyright issues that prevent the

Re: Any chance to call Tango as Extended Standard Library

2009-01-23 Thread Christopher Wright
Lars Ivar Igesund wrote: druntime should certainly not become any bigger (in scope), as that would defeat the purpose of separating the runtime from userspace in the first place. The topic of common userspace functionality should be kept separate from the topic of druntime. Okay, how about

Re: The magic behind foreach (was: Re: Descent 0.5.3 released)

2009-01-23 Thread Christopher Wright
Bill Baxter wrote: It's not? foreach(i; things) { if (i==a) continue; if (i==b) break; if (i==d) return; if (i==c) goto somewhere; } Those are all fairly common things to do from inside the 'dg' call. The int is how the compiler distinguishes which case got you out of

Re: The magic behind foreach (was: Re: Descent 0.5.3 released)

2009-01-22 Thread Christopher Wright
Ary Borenszweig wrote: If the compiler can transform a foreach into an opApply call, passing the foreach body and converting breaks to return 1 statements... can't opApply be specified as: int opApply(void delegate(ref uint) dg) { // note: delegate returns void } and the compiler transforms

Re: Templates and virtual functions

2009-01-21 Thread Christopher Wright
dsimcha wrote: Every once in a while, it comes up on this NG that a significant limitation of templates is that they can't add virtual functions to classes. Of course, removing this limitation for the general case is impossible w/o completely changing the compilation model in ways that are bad

.tupleof.stringof

2009-01-21 Thread Christopher Wright
Check this out! class Foo { int someField; } pragma (msg, Foo.tupleof[0].stringof); // int pragma (msg, Foo.tupleof[0].mangleof); // someField Why is this? It's counterintuitive.

Re: .tupleof.stringof

2009-01-21 Thread Christopher Wright
Christopher Wright wrote: Christopher Wright wrote: Check this out! class Foo { int someField; } pragma (msg, Foo.tupleof[0].stringof); // int pragma (msg, Foo.tupleof[0].mangleof); // someField Why is this? It's counterintuitive. Oops, no. mangleof does report the mangled name of the input

Re: .tupleof.stringof

2009-01-21 Thread Christopher Wright
Christopher Wright wrote: Check this out! class Foo { int someField; } pragma (msg, Foo.tupleof[0].stringof); // int pragma (msg, Foo.tupleof[0].mangleof); // someField Why is this? It's counterintuitive. Okay, no, this example is a shorter version of something else that exemplified

Re: compile time output

2009-01-20 Thread Christopher Wright
Sergey Gromov wrote: Comment out the traits and it compiles. Traits are supposed to be compile-time. How's that possible for them to prevent compile-time evaluation? It's the amazing powers of the DMD CTFE engine! And it's why I don't use d2 these days. I think I'll dust off some old code

Re: loop through specific class members

2009-01-20 Thread Christopher Wright
Jarrett Billingsley wrote: On Tue, Jan 20, 2009 at 10:29 AM, Trass3r mrmoc...@gmx.de wrote: It seems like there is no way to automatically get the class methods in D1 currently?! __traits isn't supported, std.traits doesn't give anything usable, .tupleof only gets the fields (plus only giving

Re: Any chance to call Tango as Extended Standard Library

2009-01-19 Thread Christopher Wright
Jason House wrote: void iterateOverArray(T)(T[] arr){ foreach (i; 0..arr.length) yield(arr[i]); } Coroutines are the slowest option, but the easiest to write. It takes 32 instructions or so to switch to or from a coroutine on x86. I'm not sure how that translates in terms of memory

Re: Delegate contravariance

2009-01-19 Thread Christopher Wright
Jason House wrote: Silvio Ricardo Cordeiro wrote: Is there any good reason why the following code doesn't work? The function foo requires as its argument a delegate that receives a B. This means that, because of the type soundness of the D language, the delegate will only be called with

Re: Any chance to call Tango as Extended Standard Library

2009-01-18 Thread Christopher Wright
Andrei Alexandrescu wrote: John Reimer wrote: The danger, of course, is that Tango will not be taken seriously again for D 2.0. If Tango manages to garner the lion-share of popularity as they did with D 1.0 (LDC compiler suite is one example of the significant sway Tango has had on D 1.0 ),

Re: confused with some_var.dup

2009-01-17 Thread Christopher Wright
Rainer Deyke wrote: Christopher Wright wrote: You can create a COW array struct pretty easily. However, this will be pretty slow in a lot of cases. A built-in COW type does not need to be slow! The compiler can use static analysis to eliminate unnecessary copies, and reference counting can

Re: Profiler Speed

2009-01-15 Thread Christopher Wright
bearophile wrote: Nick Sabalausky: Isn't that kind of a common thing with profilers in general? Any physical measure alters the thing to be measured, but with a good enough brain you can generally invent ways to decrease such alteration to tolerable levels. So it's a matter of inventing

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

Re: Properties

2009-01-13 Thread Christopher Wright
Benji Smith wrote: Nick Sabalausky wrote: John Reimer terminal.n...@gmail.com wrote in message news:28b70f8c119528cb42154f5d1...@news.digitalmars.com... Hello Nick, But, of course, adjectives (just like direct/indirect objects) are themselves nouns. Umm... May I make a little correction

Re: Properties

2009-01-12 Thread Christopher Wright
Miles wrote: - int func1() { return 1; } auto a = func1; // 'a' is a pointer to func1 auto b = func1;// ERROR, or deprecated way of above auto c = func1(); // calls func1 and returns int 1 int function() func2 = func1;

Re: Purity (D2 standard libraries / object.d)

2009-01-11 Thread Christopher Wright
Walter Bright wrote: Christopher Wright wrote: Stewart Gordon wrote: Stewart Gordon wrote: snip Walter, before you go and implement any of this, I must point out that it's spelt memorization and memorize. (Or memorisation and memorise if you're British, but that's an aside.) Or maybe

Re: Properties

2009-01-11 Thread Christopher Wright
Denis Koroskin wrote: On Thu, 08 Jan 2009 03:45:08 +0300, Vishaal vish...@nospam.com wrote: Properties, such as array.length, should return lvalues to allow: a.length += 8; or other similar statements. I'd like to point out another related issue that everyone seems to miss. snip struct

Re: Purity (D2 standard libraries / object.d)

2009-01-11 Thread Christopher Wright
Bill Baxter wrote: But the call for a memoization thingy I just don't get. No way that should be a compiler feature, just far too many ways to memoize with too many different tradeoffs. And a memoizing wrapper function basically loses nothing in terms of expressiveness. --bb The ability for

Re: Interfaces and Template Specializations

2009-01-11 Thread Christopher Wright
Björn T. Herzig wrote: where can I get that version? I'm currently using dmd_2.014-052208_i386.deb from the download page. never saw a newer version. Right now my only possibility to use D is inside of an ubuntu vm which is not really the greatest way... i'd really like to know if dmd will be

Re: Purity (D2 standard libraries / object.d)

2009-01-10 Thread Christopher Wright
Stewart Gordon wrote: Stewart Gordon wrote: snip Walter, before you go and implement any of this, I must point out that it's spelt memorization and memorize. (Or memorisation and memorise if you're British, but that's an aside.) Or maybe not... http://en.wikipedia.org/wiki/Memoization

Re: DBC TM

2009-01-10 Thread Christopher Wright
Nick Sabalausky wrote: Lurker lur...@mailinator.com wrote in message news:gkanpu$2l9...@digitalmars.com... Design by Contract is a registered trademark[1] of Interactive Software Engineering, Inc. in the United States http://en.wikipedia.org/wiki/Design_by_contract Does Digital Mars has

Re: OT: Less-restrictive alternative to XML and XML visualizers?

2009-01-09 Thread Christopher Wright
Nick Sabalausky wrote: I have a need for an inexpensive (preferably freeware or open-source, obviously), alternate to using XML and an XML viewer (such as MindFusion's XML Viewer). The main problem with XML is that I need something that will allow node names to contain any arbitrary text

Re: division of objects into classes and structures is bad

2009-01-05 Thread Christopher Wright
Weed wrote: Who agrees with me? There are still ideas as it is possible to solve this problem and not to destroy language? When you reply to your reply to your reply to your post and nobody else replies to any of your posts, you might start thinking that nobody agrees with you, or cares

Re: 128 bit signed and unsigned integer types

2008-12-30 Thread Christopher Wright
Don wrote: Daniel Keep wrote: Chad J wrote: Cool, but don't name it FixedInt unless it implements fixed point arithmetic. Fine, but don't name it 'Integer' or 'Int' unless it can store any value in the set of integers; you know, the infinite one that doesn't have that stupid 1 + T.max =

Re: Operator overloading -- lets collect some use cases

2008-12-30 Thread Christopher Wright
Don wrote: Some observations based on the use cases to date: (1) a += b is ALWAYS a = a + b (and likewise for all other operations). opXXXAssign therefore seems to be a (limited) performance optimisation. The compiler should be allowed to synthesize += from +. This would almost halve the

Re: division of objects into classes and structures is bad

2008-12-30 Thread Christopher Wright
Don wrote: The creation of temporaries during expressions is something I'm currently working on solving. The case you mentioned is addressed by a proposal I made long ago: The easiest way is to add an intermediate struct. This takes a fair bit of manual effort, though, and prevents you from

Re: Can pure functions accept const parameters or only invariant ?

2008-12-29 Thread Christopher Wright
mastrost wrote: So why is this code accepted by the compiler? I'm not sure whether it's intentional, but a pure function is correct for mutable input as well as invariant input (barring threading issues), so this avoids code duplication.

Re: dmd platform support - poll

2008-12-28 Thread Christopher Wright
Andrei Alexandrescu wrote: Well I'm not going to continue this asinine but you said this/but I didn't mean that exchange as it's a waste of your time and mine, to say nothing about that Christmas spirit. On Christmas day you can't get sore. Your fellow man you must adore. There's time to rob

Re: compile-time initialization of objects need?

2008-12-28 Thread Christopher Wright
Weed wrote: It not syntactic sugar. I suggest not to waste time at all performance on run-time initialization of objects and check of side conditions on a course of performance of the program. Sorry, syntactic sugar and some minor optimizations.

Re: Operator overloading -- lets collect some use cases

2008-12-28 Thread Christopher Wright
Don wrote: There's been some interesting discussion about operator overloading over the past six months, but to take the next step, I think we need to ground it in reality. What are the use cases? I think that D's existing opCmp() takes care of the plethora of trivial cases where , = etc are

Re: dmd platform support - poll

2008-12-27 Thread Christopher Wright
Nick Sabalausky wrote: Yigal Chripun yigal...@gmail.com wrote in message news:gj6e3m$1il...@digitalmars.com... two things: a) current hardware is 64bit (if you go and buy a PC), Ah ha, there's that usual if you go and buy a PC catch. Which begs the question, why would I? My existing system

Re: dmd platform support - poll

2008-12-27 Thread Christopher Wright
Tim Keating wrote: Supporting .net would give you access to the most modern and probably best-currently-supported Windows API. It would, if you counted Mono, add a very nice cross-platform UI framework. Finally, depending on what version was supported, it might enable you to write Silverlight

Re: Operator overloading

2008-12-23 Thread Christopher Wright
Denis Koroskin wrote: Slightly off-topic. How would you implement, say, LIKE condition? Similar to the following, perhaps: Query query = Select(a).Where(id.Like(%substring%)); You could implement == the same way: Query query = Select(a).Where(id.EqualsTo(5)); downs way: auto query1 =

Re: DMD 1.038 and 2.022 releases

2008-12-22 Thread Christopher Wright
John Reimer wrote: Hello Derek, Just thinking out aloud ... If two modules import each other and this can be 'fixed' by instead having both modules as a single module, what is stopping the compiler from just pretending that they are a single module for compilation purposes? This does assume

Re: Descent 0.5.3 released

2008-12-22 Thread Christopher Wright
Tim M wrote: I dont think the allround ide is a problem anymore with eclipse available. Whats missing is a good gui builder. If you know of one other than entice though can you please reply with the links. No top-posting, please. I use Glade. It works reasonably well for small projects.

Re: Descent 0.5.3 released

2008-12-22 Thread Christopher Wright
BCS wrote: Reply to Ary, And a question: what would you like to see next in Descent? Better template support. I now have 2 libs that are just flat uneditable under descent (scrapple.units and scrapple.dparse) both bring it down to a stand still if not crash and hand it out right. I'd love

Re: Moving GC

2008-12-13 Thread Christopher Wright
dsimcha wrote: == Quote from Christopher Wright (dhase...@gmail.com)'s article It means that you can't use one block for objects of multiple types. Sure you can, without being any worse off than under the current scheme. Mark the contents of the memory as an array of void*s. This would

Re: Notes on Defective C++

2008-12-13 Thread Christopher Wright
Jim Hewes wrote: Maybe it's better to think of memory and non-memory resources as different things and handle them differently as opposed to lumping them together using the same mechanism. I'm not sure if there is already a way to deal with this in D as I'm not quite that familiar with D. It

Re: confusing (buggy?) closure behaviour

2008-12-13 Thread Christopher Wright
Zoran Isailovski wrote: Oh... I've got the wrong impression from the papers about D. (But then, why would someone design an *unsafe* language *by intention*??? For that, we've got C and C++, don't we?) Anyway, I've been looking for a modern and *safe* language, but without the overkill of a

Re: Moving GC

2008-12-12 Thread Christopher Wright
dsimcha wrote: == Quote from Sean Kelly (s...@invisibleduck.org)'s article == Quote from Christopher Wright (dhase...@gmail.com)'s article This isn't unreasonable, and it really just depends on how complete and how fast D's runtime reflection is. This would incur more memory overhead as well

Re: More phpBB like forum?

2008-12-11 Thread Christopher Wright
Brad Roberts wrote: However, since it really is a pub/sub system, it'd be interesting to look for interesting one - many programatic use cases that could take advantage of it. I'm looking into creating a service bus with twitter as its transport mechanism. Unfortunately, I think it won't be

Re: Notes on Defective C++

2008-12-09 Thread Christopher Wright
Jim Hewes wrote: Yes. Thanks for the example. I do that sort of thing a lot, and it applies to anything with a handle such as mutexes, files, etc. In garbage-collected languages, what am I supposed to do there? It would seem that garbage collection and exceptions don't play nice together. Or

Re: CTFE - filling an array

2008-12-09 Thread Christopher Wright
The Anh Tran wrote: static double[N] dd = void; dd is not a compile-time constant. static auto tmp = f!(N).fn(dd); The initializer of tmp must be a compile-time constant, but since dd is not a compile-time constant, you can't use CTFE on fn.

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Christopher Wright
Daniel White wrote: That would be a bad idea. Then how would you do manual memory management in the few cases that absolutely require it? Two ways. Either: a: being able to lock the variable so that the garbage collector can't touch it until you unlock it. If you have a reference to the

Re: A lightweight module for class extensions in D

2008-12-07 Thread Christopher Wright
Nick Sabalausky wrote: I'd rather have a type that all other types derive from. Sort of like Object (or is it object?), but serves as the base type for all types, not just classes. Not sure if this would be possible though (having vtables for every int and char in the program doesn't sound

Re: toString ugliness

2008-12-07 Thread Christopher Wright
Ary Borenszweig wrote: Jarrett Billingsley escribió: On Sun, Dec 7, 2008 at 7:12 AM, Ary Borenszweig [EMAIL PROTECTED] wrote: definition of toString that does match. Most of the time ADL leads to confusing behavior, which is why it was dropped in D. But the overloading is obvious! It looks

Re: toString ugliness

2008-12-07 Thread Christopher Wright
Sergey Gromov wrote: Not correct. C++ uses the same rules to build overload sets as D. That is, a function declaration in an inner scope hides any function declarations with the same name in outer scopes. I /think/ there should be a good rationale behind this design. I've been using C++

Re: druntime thread_needLock()

2008-12-06 Thread Christopher Wright
Fawzi Mohamed wrote: So yes one could probably switch back to the old Phobos style. I would guess that it is not really a common situation for a program to become single threaded again, though... Fawzi At work, we have a single-threaded application -- everything happens on the GUI thread.

Re: A lightweight module for class extensions in D

2008-12-05 Thread Christopher Wright
Gregor Richards wrote: I ran into a situation where I needed (essentially) the visitor pattern, but the visitor pattern sucks, so I wanted to make something like class extensions instead (that is, methods added to a class outside of the class definition). I usually use this pattern but make

Re: Tail call elimination

2008-12-04 Thread Christopher Wright
Nick Sabalausky wrote: Christopher Wright [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Nick Sabalausky wrote: On a side note, stack overflows are still possible anyway (whether functional or imperative). Is there a reason (other than inertia) that stack frames aren't set up like

Re: Function literals -- strange behavior

2008-12-04 Thread Christopher Wright
Justin wrote: Ahh, I thought it would some stupid oversight on my part. This works: module functionliteral; import std.stdio; static void main() { int[] values = [1,2,4,8]; writefln(Reduce(values, function int(int x, int y) { return x + y; })); writefln(Reduce(values,

Re: Tail call elimination

2008-12-03 Thread Christopher Wright
Nick Sabalausky wrote: On a side note, stack overflows are still possible anyway (whether functional or imperative). Is there a reason (other than inertia) that stack frames aren't set up like a dynamic array to grow as needed? (Of course, I can understand not doing that during a debug build

Re: Identity of interfaces (or not)

2008-12-02 Thread Christopher Wright
BCS wrote: Reply to Tomas, The problem is that B has two vtables that implement the interface I. However, in A.addChild, i.parent get's the first one (introduced by A), and in main, it gets the second one (J , which derived from I). The identity check then fails because the pointers aren't the

Re: Compile-time exceptions

2008-11-25 Thread Christopher Wright
bearophile wrote: Christopher Wright Wrote: I don't know what this is doing. That code fragment won't compile, and it isn't showing usage. Sorry: struct _add { T opCall(T.init + T.init)(T x) { return x+x; } } _add add; Now you can give it to a function, without the need of specializing

Re: Compile-time exceptions

2008-11-24 Thread Christopher Wright
bearophile wrote: But at the moment I haven't found ways to unit test the first two static asserts, so I just put tests in the unittest for them, and I comment them out to make the unittest run. assert (!is (typeof (nest(1, 1, 1; // int is not callable If you're using d2: assert

Re: D

2008-11-23 Thread Christopher Wright
Tony wrote: On libraries: I am replacing (lots done already) the C++ std library. It's icky. You must be a bored masochist.

Re: foreach

2008-11-23 Thread Christopher Wright
Bill Baxter wrote: On Sun, Nov 23, 2008 at 3:25 PM, Jarrett Billingsley [EMAIL PROTECTED] wrote: On Sat, Nov 22, 2008 at 11:40 PM, Sam S E [EMAIL PROTECTED] wrote: Does foreach use delegates? Isn't that unnecessary overhead? --Sam It does use delegates, for iterating over most types. When

Re: which version of D for beginers?

2008-11-23 Thread Christopher Wright
Kagamin wrote: Hoenir Wrote: Lutger schrieb: There are a few changes that need to be done when porting code from D1 to D2. It may be helpful to find out what those are at an early stage and program your applications with these in mind. That will help when D2 is more stabilized and you want to

Getting environment variables?

2008-11-22 Thread Christopher Wright
Hey all, How do I get environment variables in a D program? I specifically want the path to a user's home folder. Ta muchly.

Re: D

2008-11-20 Thread Christopher Wright
dsimcha wrote: == Quote from bearophile ([EMAIL PROTECTED])'s article D is a fringe language, and it's not an easy one (system language and all that), so there's never shortage of unusual people in this newsgroup :-) Java groups are so boooring compared to this one :-) Bear hugs, bearophile

Re: access subclass functions

2008-11-20 Thread Christopher Wright
Saaa wrote: from the list (private, protected, public) pick public. Note the difference between peel and peal. :) public YellowBanana: Banana { void doStuff() { bool e = peel(); //visible from derived //class when defined protected or public. } } Banana a =

Re: Some people to convert jdo2.2 to d ?

2008-11-16 Thread Christopher Wright
Marcin Kuszczak wrote: Please remember that I am not saying that entities are solution for everything. I am just saying that in many cases (most?) it is sufficient enough to use entities instead objects. Especially when you have to use data in presentation layer. In my program I needed graph

Re: Some people to convert jdo2.2 to d ?

2008-11-13 Thread Christopher Wright
Marcin Kuszczak wrote: Christopher Wright wrote: Aarti_pl wrote: ...and this high-level design is IMHO mistake. Especially mapping relations from db to objects. Well maybe someone will give me examples where domain objects are more useful than relations? From my observations presentation

Re: Some people to convert jdo2.2 to d ?

2008-11-12 Thread Christopher Wright
Aarti_pl wrote: dolive pisze: the ddbi progress is too really slow, difficult to look forward toĄŁ data nucleus is more high-level like Hibernate. ...and this high-level design is IMHO mistake. Especially mapping relations from db to objects. Well maybe someone will give me examples where

Re: How much time will D1 be around?

2008-11-11 Thread Christopher Wright
Walter Bright wrote: Christopher Wright wrote: Even better, will the large body of existing bugs ever be fixed? 10 to 20 get fixed every release. True, sorry. I just tend to run into a few of them consistently that haven't gotten in yet.

Re: including a file

2008-11-10 Thread Christopher Wright
Jarrett Billingsley wrote: On Sun, Nov 9, 2008 at 10:18 PM, James [EMAIL PROTECTED] wrote: i created to include file, 1 with 'module xxx' declaration and the other without it. but i still can import both files. what is the diff here? Not a lot. The module declaration doesn't serve much

Dunit 0.2

2008-11-08 Thread Christopher Wright
Introducing DUnit 0.2, with even more inconsistent capitalization! Wow, it's been ages. I've been working off trunk so long I didn't realize there was a 0.1 release. Wow. We've come a long way in the past eight months. About as long as I could have come in two weeks, if I were paying

<    1   2   3   4   5