Re: D2 port of Tango

2011-12-25 Thread Damian Ziemba
On Saturday, 24 December 2011 at 22:15:59 UTC, Jordi Sayol wrote: Al 24/12/11 14:20, En/na mta`chrono ha escrit: Unlike SiegeLord's branch I've removed tango's runtime and build on top of druntime. This step is inevitable in order to make tango and phobos work side by side. SiegeLord's

Re: Carmack about static analysis

2011-12-25 Thread Kapps
Universal Function Call Syntax. C# calls them extension methods. Basically, the ability to call a method directly on a class (in the form of A.MyMethod) without it being declared in the class. Usually just a static/global method that gets rewritten. Instead of MyMethod(A), you can use

D - dynamic_cast only?

2011-12-25 Thread Steve Teale
I'll try again on this. My reading of the current documentation on casts leaves me with the impression that D now has only the equivalent of the C++ dynamic_cast. This seems unreasonably restrictive given that C++ has traditional C- style cast, dynamic_cast, static_cast, and reinterpret_cast -

Re: D - dynamic_cast only?

2011-12-25 Thread Vladimir Panteleev
On Sunday, 25 December 2011 at 08:37:21 UTC, Steve Teale wrote: I'll try again on this. My reading of the current documentation on casts leaves me with the impression that D now has only the equivalent of the C++ dynamic_cast. This seems unreasonably restrictive given that C++ has

Re: Carmack about static analysis

2011-12-25 Thread Chad J
On 12/25/2011 02:57 AM, Kapps wrote: Universal Function Call Syntax. C# calls them extension methods. Basically, the ability to call a method directly on a class (in the form of A.MyMethod) without it being declared in the class. Usually just a static/global method that gets rewritten. Instead

Re: D - dynamic_cast only?

2011-12-25 Thread bearophile
Steve Teale: My reading of the current documentation on casts leaves me with the impression that D now has only the equivalent of the C++ dynamic_cast. I'd like this in Phobos: http://d.puremagic.com/issues/show_bug.cgi?id=5559 Bye, bearophile

Re: Carmack about static analysis

2011-12-25 Thread SomeDude
On Saturday, 24 December 2011 at 20:19:48 UTC, Andrei Alexandrescu wrote: Analogies of programming language with human language are flawed and take nowhere interesting. The only text that gets close to the level of precision and non-ambiguity needed is legal text; reading any amount of legal

Re: D - dynamic_cast only?

2011-12-25 Thread Steve Teale
On Sun, 25 Dec 2011 08:37:21 +, Steve Teale wrote: So what do you think is happening here? ColorSelectionDialog csd = new ColorSelectionDialog(Choose a Color); writefln(csd %s, csd); void* vp = cast(void*) csd.getColorSelection(); ColorSelection cs = cast(ColorSelection) vp;

Re: Carmack about static analysis

2011-12-25 Thread simendsjo
On 25.12.2011 00:44, Timon Gehr wrote: Not really. Functional style code tends to be conceptually simpler. Having code that is more readable can help. Getting rid of (({return {return}}){return()}) makes the code more readable, whereas excessively shortening identifiers does the opposite. See

Re: Carmack about static analysis

2011-12-25 Thread Jacob Carlborg
On 2011-12-25 02:20, Adam D. Ruppe wrote: On Saturday, 24 December 2011 at 23:51:57 UTC, bearophile wrote: Using certain abstractions sometimes helps to write one idea only once in a program. Etc. This is the biggest one, and applies to all kinds of code. I like to write little functions with

Re: Proposal for custom time string formatting in std.datetime

2011-12-25 Thread Jacob Carlborg
On 2011-12-25 04:05, zhang wrote: On Fri, 23 Dec 2011 02:21:37 -, Walter Bright newshou...@digitalmars.com wrote: On 12/22/2011 11:25 AM, Piotr Szturmaj wrote: I wish D could support partial modules - partial as analogy to C#'s partial classes. module std.datetime-unit1; import

Re: D - dynamic_cast only?

2011-12-25 Thread Vladimir Panteleev
On Sunday, 25 December 2011 at 13:39:15 UTC, Steve Teale wrote: The segfault is presumably because Widget does not have a setCurrentColor method, but why is the cast being ignored? Is the compiler optimizing the intermediate cast to void away? I don't find the asm from obj2asm helpful. I

Re: Carmack about static analysis

2011-12-25 Thread Jacob Carlborg
On 2011-12-25 05:44, Andrei Alexandrescu wrote: On 12/24/2011 07:20 PM, Adam D. Ruppe wrote: On Saturday, 24 December 2011 at 23:51:57 UTC, bearophile wrote: Using certain abstractions sometimes helps to write one idea only once in a program. Etc. This is the biggest one, and applies to all

Re: Proposal for custom time string formatting in std.datetime

2011-12-25 Thread Jakob Ovrum
On Sunday, 25 December 2011 at 14:00:58 UTC, Jacob Carlborg wrote: On 2011-12-25 04:05, zhang wrote: On Fri, 23 Dec 2011 02:21:37 -, Walter Bright newshou...@digitalmars.com wrote: On 12/22/2011 11:25 AM, Piotr Szturmaj wrote: I wish D could support partial modules - partial as analogy

Re: Looking for SciLib

2011-12-25 Thread Lars T. Kyllingstad
On Tue, 20 Dec 2011 23:38:05 +0100, Paul D. Anderson wrote: I recall seeing several times someone mentioning they were working on a project called SciLib or SciLb or similar. If you're that person or if you know who that person is, could you send me an e-mail? Hi! Author of SciD here. I

Re: Could we use something better than zip for the dmd package?

2011-12-25 Thread Nick Sabalausky
Jacob Carlborg d...@me.com wrote in message news:jd4qg2$9r5$1...@digitalmars.com... On 2011-12-23 22:38, Somedude wrote: Le 23/12/2011 18:11, Nick Sabalausky a écrit : I'm actually inching closer to being a linux guy. Being able to easily script just about everything is pretty nice, and

Re: Proposal for custom time string formatting in std.datetime

2011-12-25 Thread Jacob Carlborg
On 2011-12-25 15:31, Jakob Ovrum wrote: On Sunday, 25 December 2011 at 14:00:58 UTC, Jacob Carlborg wrote: On 2011-12-25 04:05, zhang wrote: On Fri, 23 Dec 2011 02:21:37 -, Walter Bright newshou...@digitalmars.com wrote: On 12/22/2011 11:25 AM, Piotr Szturmaj wrote: I wish D could

Ants AI, language matters

2011-12-25 Thread bearophile
Ants AI Challenge sponsored by Google is now finished, 24 people have played this contest using D2: http://aichallenge.org/language_profile.php?language=D The best D entry, by Minthos, with rank 439 (over about 8000 entries!): http://aichallenge.org/profile.php?user=4823 Minthos D2 code:

Re: D - dynamic_cast only?

2011-12-25 Thread Steve Teale
On Sun, 25 Dec 2011 15:01:31 +0100, Vladimir Panteleev wrote: I don't understand. Casting a void* to a class bypasses all static type checks. This is one of those cases where you tell the compiler that you know what you're doing - and if you try to call a method that wasn't in the original

Re: Ants AI, language matters

2011-12-25 Thread Jakob Ovrum
On Sunday, 25 December 2011 at 17:07:46 UTC, bearophile wrote: It's usually better to think of pre/post increments as returning void, and avoid code like this (but there is _far_ worse C/D code around): lokeLars = path[index--]; I agree that one should *generally* avoid this kind of code,

Re: Could we use something better than zip for the dmd package?

2011-12-25 Thread bearophile
Kagamin: Copy-deployment is an advanced format, and I think it's pretty ok for it to be 7z. I suggest to just offer both zip and 7zip files. Bye, bearophile

Re: Could we use something better than zip for the dmd package?

2011-12-25 Thread Kagamin
But not without installing 3rd party software. Windows can handle zip files out of the box. It can't handle the others. rar would have exactly the same problem as 7z files (though from what I've see rar files are much more commonly used). We _could_ use a file format other than zip, but then

Re: Could we use something better than zip for the dmd package?

2011-12-25 Thread Kagamin
I suggest to just offer both zip and 7zip files. Sure it can be done, but I doubt zip helps availability a lot.

Re: Carmack about static analysis

2011-12-25 Thread Timon Gehr
On 12/25/2011 02:44 PM, simendsjo wrote: On 25.12.2011 00:44, Timon Gehr wrote: Not really. Functional style code tends to be conceptually simpler. Having code that is more readable can help. Getting rid of (({return {return}}){return()}) makes the code more readable, whereas excessively

Mac OS X installer is for 64bit

2011-12-25 Thread Jacob Carlborg
The Mac OS X installer on dlang.org/dowloads says it is for i386 but it's actually for 64bit. -- /Jacob Carlborg

Re: Carmack about static analysis

2011-12-25 Thread Adam D. Ruppe
On Sunday, 25 December 2011 at 04:44:57 UTC, Andrei Alexandrescu wrote: I see every letter beyond this as a liability: Yeah, though like Jacob said, the implementation doesn't matter as much as the idea of giving it a name. But, if you're curious about why I wrote it long form, it's just a

Re: Carmack about static analysis

2011-12-25 Thread Timon Gehr
On 12/25/2011 11:53 PM, Timon Gehr wrote: On 12/25/2011 02:44 PM, simendsjo wrote: On 25.12.2011 00:44, Timon Gehr wrote: Not really. Functional style code tends to be conceptually simpler. Having code that is more readable can help. Getting rid of (({return {return}}){return()}) makes the

Re: Carmack about static analysis

2011-12-25 Thread bearophile
Timon Gehr: http://pastebin.com/C6vf9DQQ If possible I suggest to remove all the BigInt from the module, and put the bigint import into the main(): void main() { import std.bigint; auto h = hamming!BigInt(); writeln(take(20, h)); writeln(h()[1_691]);

Re: Carmack about static analysis

2011-12-25 Thread Timon Gehr
On 12/26/2011 12:30 AM, bearophile wrote: Timon Gehr: http://pastebin.com/C6vf9DQQ If possible I suggest to remove all the BigInt from the module, and put the bigint import into the main(): void main() { import std.bigint; auto h = hamming!BigInt(); writeln(take(20, h));

Re: Mac OS X installer is for 64bit

2011-12-25 Thread Andrei Alexandrescu
On 12/25/11 5:11 PM, Jacob Carlborg wrote: The Mac OS X installer on dlang.org/dowloads says it is for i386 but it's actually for 64bit. Fixed. Looking good? Andrei

Re: Carmack about static analysis

2011-12-25 Thread Andrei Alexandrescu
On 12/25/11 5:13 PM, Adam D. Ruppe wrote: On Sunday, 25 December 2011 at 04:44:57 UTC, Andrei Alexandrescu wrote: I see every letter beyond this as a liability: Yeah, though like Jacob said, the implementation doesn't matter as much as the idea of giving it a name. But, if you're curious

Re: Looking for SciLib

2011-12-25 Thread Jonathan M Davis
On Sunday, December 25, 2011 15:52:25 Lars T. Kyllingstad wrote: As others have pointed out, Cristi Cobzarenco forked my code when he was writing a linear algebra library for GSoC. However, in the process he has removed almost everything that is not related to linear algebra. Sounds like they

Re: Carmack about static analysis

2011-12-25 Thread Jonathan M Davis
On Saturday, December 24, 2011 21:37:12 Kapps wrote: The two biggest things that I believe D would benefit from, in terms of readability, are UFCS and C#-style lambdas (which were already discussed). Something like 'array(find(test, select!(a.name)(filter!(a.num 3)(Elements' Could be

Re: @noreturn ?

2011-12-25 Thread Jonathan M Davis
On Saturday, December 24, 2011 22:26:02 Andrei Alexandrescu wrote: On 12/24/2011 06:58 PM, Vladimir Panteleev wrote: On Saturday, 24 December 2011 at 20:09:46 UTC, bearophile wrote: GNU C has a noreturn attribute since a lot of time. I don't fully understand why such attribute is so useful

Re: Ants AI, language matters

2011-12-25 Thread Marco Leise
I posted about this contest in D.learn, so it was expectable that people try out D there without a good feel for the language and its shortcuts. Rank 439 is respectable, but I hoped for a higher ranked D entry. I don't know if there should to be an optimized boolean matrix in Phobos. Is

Re: Looking for SciLib

2011-12-25 Thread dsimcha
On Monday, 26 December 2011 at 00:46:44 UTC, Jonathan M Davis wrote: Sounds like they should probably be merged at some point. - Jonathan M Davis Yeah, I've started working on Cristi's fork now that I've built a good enough mental model of the implementation details that I can modify the

A little bug

2011-12-25 Thread Andrej Mitrovic
I've found this sort of bug in xfBuild: import std.stdio; class Deps { } struct Mod { Deps deps; } void main() { Mod[] compileArray; foreach (i; 0 .. 2) { compileArray ~= Mod(new Deps); } foreach (mod; compileArray) { mod.deps = null; } foreach

Re: Carmack about static analysis

2011-12-25 Thread Adam D. Ruppe
On Monday, 26 December 2011 at 02:31:52 UTC, Adam D. Ruppe wrote: I like an individual line of code to be dumb as a rock anyway. I'm reminded of a discussion I had on another forum, where someone suggested this might be because I started with assembly language. It might be that those first

Re: Carmack about static analysis

2011-12-25 Thread Adam D. Ruppe
On Monday, 26 December 2011 at 00:40:47 UTC, Andrei Alexandrescu wrote: I understand. Personally, I am unable to bring myself to fathom why writing this has any advantage: if(condition) return false just avoids a negation in the condition. It's easier to miss a ! entirely than to miss a

Re: Carmack about static analysis

2011-12-25 Thread deadalnix
Le 25/12/2011 05:27, Andrei Alexandrescu a écrit : Got the GC book this morning, already read 2.5 chapters :o). Andrei You'll find that you can do a lot when GC is aware of immutability (in functionnal languages, most things tends to be immutable). In the actual state of druntime, the GC

Re: A little bug

2011-12-25 Thread Vladimir Panteleev
On Monday, 26 December 2011 at 02:06:18 UTC, Andrej Mitrovic wrote: This will print false, false. After reading the code, I thought the surprise was that it printed true :) Perhaps making the default foreach behavior to make copies of structs wasn't the best idea, also due to performance

Re: Carmack about static analysis

2011-12-25 Thread Andrei Alexandrescu
On 12/25/11 8:56 PM, deadalnix wrote: Le 25/12/2011 05:27, Andrei Alexandrescu a écrit : Got the GC book this morning, already read 2.5 chapters :o). Andrei You'll find that you can do a lot when GC is aware of immutability (in functionnal languages, most things tends to be immutable). In

versions and 32 vs 64-bit code

2011-12-25 Thread Nathan Coe
Is there a way to change what is compiled in based on whether the -m32 or -m64 option is chosen? I can see that there are predefined versions (for X86 and X86_64 e.g.), but I don't know if this is based on the compile options, or the platform the compilation is being performed on. As an example,

Re: versions and 32 vs 64-bit code

2011-12-25 Thread Vladimir Panteleev
On Monday, 26 December 2011 at 05:41:11 UTC, Nathan Coe wrote: As an example, if I am compiling on a 64-bit intel machine, is the version X86 or X86_64 set by default? The predefined version identifiers specify the *target* architecture. Note that the default target architecture matches the

Re: Could we have mod in std.math?

2011-12-25 Thread Don
On 24.12.2011 22:12, bearophile wrote: Caligo: I'm hoping to see something like the above mod function in Phobos someday. I'd like that, for both int/long/BigInts. And I'd like some functions for BigInts: - divmod: returns both % and div and %, but it's more efficient if you need both

Re: Could we have mod in std.math?

2011-12-25 Thread Walter Bright
On 12/25/2011 10:57 PM, Don wrote: On 24.12.2011 22:12, bearophile wrote: Caligo: I'm hoping to see something like the above mod function in Phobos someday. I'd like that, for both int/long/BigInts. And I'd like some functions for BigInts: - divmod: returns both % and div and %, but it's

GetAndSet function (corresponding to cas function)

2011-12-25 Thread Adrian Mercieca
Hi folks, Is there a GetAndSet function (corresponding to cas (compare and set) function) in D? Thanks.

Re: Reading about D: few questions

2011-12-25 Thread Denis Shelomovskij
25.12.2011 0:48, Mr. Anonymous пишет: Actually, when I think of it: int a_orig = a++; int[] arr_orig = arr[]++; Should be read as: int a_orig = a; ++a; int[] arr_orig = arr[]; ++arr[]; (If I'm not mistaken, it was written in the TDPL book) Which means no copy of arr is made, and both arrays

Re: GetAndSet function (corresponding to cas function)

2011-12-25 Thread Mike Wey
On 12/25/2011 09:25 AM, Adrian Mercieca wrote: Hi folks, Is there a GetAndSet function (corresponding to cas (compare and set) function) in D? Thanks. core.atomic.cas http://dlang.org/phobos/core_atomic.html#cas -- Mike Wey

Re: GetAndSet function (corresponding to cas function)

2011-12-25 Thread Adrian Mercieca
On Sun, 25 Dec 2011 13:37:32 +0100, Mike Wey wrote: On 12/25/2011 09:25 AM, Adrian Mercieca wrote: Hi folks, Is there a GetAndSet function (corresponding to cas (compare and set) function) in D? Thanks. core.atomic.cas http://dlang.org/phobos/core_atomic.html#cas I know of the cas

dmd linker (OPTLINK) gives Error 42: Symbol Undefined when using extern

2011-12-25 Thread Tal
Linking the following two files gives me a link-error: a.d: import std.stdio; extern (D) string test (); void main() { writeln(test()); readln(); } b.d: string test () {

Re: dmd linker (OPTLINK) gives Error 42: Symbol Undefined when using extern

2011-12-25 Thread Tal
I want to save the hInstance of WinMain so I would be able to use it later in some other module. So how do I accomplish that ?

Re: dmd linker (OPTLINK) gives Error 42: Symbol Undefined when using extern

2011-12-25 Thread Joshua Reusch
Am 25.12.2011 22:37, schrieb Tal: I want to save the hInstance of WinMain so I would be able to use it later in some other module. So how do I accomplish that ? just define a public variable in the global scope.

Re: dmd linker (OPTLINK) gives Error 42: Symbol Undefined when using extern

2011-12-25 Thread Tal
I'm quite new to this language, could you please provide a short snippet of code to clarify ?

Re: dmd linker (OPTLINK) gives Error 42: Symbol Undefined when using extern

2011-12-25 Thread Joshua Reusch
Am 25.12.2011 23:26, schrieb Tal: I'm quite new to this language, could you please provide a short snippet of code to clarify ? --- a.d: import std.stdio; import b; void main() { writeln(some_var from Module b: \, b.some_var, \); } --- b.d: public string some_var = Hello, world!; //you

Re: dmd linker (OPTLINK) gives Error 42: Symbol Undefined when using extern

2011-12-25 Thread Joshua Reusch
Am 25.12.2011 22:37, schrieb Tal: I want to save the hInstance of WinMain so I would be able to use it later in some other module. So how do I accomplish that ? If you don't know: You can also get the HINSTANCE with GetModuleHandle(NULL);

Re: dmd linker (OPTLINK) gives Error 42: Symbol Undefined when using extern

2011-12-25 Thread Jakob Ovrum
On Sunday, 25 December 2011 at 22:46:33 UTC, Joshua Reusch wrote: public string some_var = Hello, world!; It's important to note that public is the default access level here.

[Issue 7133] [tdpl] There should be no empty statement

2011-12-25 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7133 --- Comment #11 from Jakob Ovrum jakobov...@gmail.com 2011-12-25 01:03:29 PST --- (In reply to comment #10) In fact the oddity is that labels are considered to be statements, yet they don't end with a semicolon. Block, if, while, do, for,

[Issue 5605] [tdpl] foreach with ranges doesn't support opSlice()

2011-12-25 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5605 Kenji Hara k.hara...@gmail.com changed: What|Removed |Added Keywords||patch, rejects-valid

[Issue 4596] [tdpl] Rebinding *this* in class method compiles

2011-12-25 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4596 Kenji Hara k.hara...@gmail.com changed: What|Removed |Added Keywords||patch

[Issue 7161] Passing string literal by ref changes its bounds forever

2011-12-25 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7161 Denis verylonglogin@gmail.com changed: What|Removed |Added Status|NEW |RESOLVED

[Issue 4539] Refuse assignment to string literal

2011-12-25 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4539 Denis verylonglogin@gmail.com changed: What|Removed |Added CC|

[Issue 4539] Refuse assignment to string literal

2011-12-25 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4539 --- Comment #15 from Kenji Hara k.hara...@gmail.com 2011-12-25 07:29:50 PST --- Updated patch. https://github.com/D-Programming-Language/dmd/pull/164 A string literal should be able to bind a reference to static array type. In the context of

[Issue 5605] [tdpl] foreach with ranges doesn't support opSlice()

2011-12-25 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5605 Walter Bright bugzi...@digitalmars.com changed: What|Removed |Added Status|NEW |RESOLVED

[Issue 4647] [tdpl] Cannot explicitly call final interface method, ambiguous calls allowed

2011-12-25 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4647 Walter Bright bugzi...@digitalmars.com changed: What|Removed |Added Status|NEW |RESOLVED

[Issue 7164] New: Can't inline function literal

2011-12-25 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7164 Summary: Can't inline function literal Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD

[Issue 7165] New: [CTFE] ice converting null pointer to bool with constant member function

2011-12-25 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7165 Summary: [CTFE] ice converting null pointer to bool with constant member function Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW