Re: Getting equivalent elements in a range/array

2011-05-08 Thread Ali Çehreli
On 05/07/2011 09:07 PM, Andrej M. wrote: I want to turn this: auto arr = [1, 1, 2, 3, 4, 4]; into this: auto arr2 = [[1, 1], [2], [3], [4, 4]]; I want an array of arrays of the same elements. Lazy or not, I don't care. I thought I could get away with this inside some while loop: auto equals =

private module stuff

2011-05-08 Thread Sean Cavanaugh
So I was learning how to make a module of mine very strict with private parts, and was surprised I could only do this with global variables and functions. Enums, structs, and classes are fully visible outside the module regardless of being wrapped in a private{} or prefixed with private.

Re: Shouldn't duplicate functions be caught by DMD?

2011-05-08 Thread bearophile
Andrej Mitrovic: I think the compiler should check catch these mistakes at compile-time. I suggest to add an enhancement request in Bugzilla. Bugzilla entries are a form of voting by themselves too. Bye, bearophile

Re: private module stuff

2011-05-08 Thread bearophile
Sean Cavanaugh: So I was learning how to make a module of mine very strict with private parts, and was surprised I could only do this with global variables and functions. Enums, structs, and classes are fully visible outside the module regardless of being wrapped in a private{} or

Re: Getting equivalent elements in a range/array

2011-05-08 Thread bearophile
Andrej M.: I want to turn this: auto arr = [1, 1, 2, 3, 4, 4]; into this: auto arr2 = [[1, 1], [2], [3], [4, 4]]; I want an array of arrays of the same elements. Lazy or not, I don't care. Currently if you use group like this: writeln(arr.group()); You get: [Tuple!(int,uint)(1, 2),

Re: private module stuff

2011-05-08 Thread Jonathan M Davis
Sean Cavanaugh: So I was learning how to make a module of mine very strict with private parts, and was surprised I could only do this with global variables and functions. Enums, structs, and classes are fully visible outside the module regardless of being wrapped in a private{}

Re: private module stuff

2011-05-08 Thread bearophile
Jonathan M Davis: They're private _access_ but still visible. In my opinion this is not good, it looks like a messy special case. I believe that it's necessary for stuff like where various functions in std.algorithm return auto and return a private struct which you cannot construct

Re: private module stuff

2011-05-08 Thread Jonathan M Davis
Jonathan M Davis: They're private _access_ but still visible. In my opinion this is not good, it looks like a messy special case. I believe that it's necessary for stuff like where various functions in std.algorithm return auto and return a private struct which you cannot construct

Re: Linux: How to statically link against system libs?

2011-05-08 Thread Nick Sabalausky
Nick Sabalausky a@a.a wrote in message news:iq2g72$ngp$1...@digitalmars.com... Aggg!!! God damnnit, I officially fucking hate linux now... (not that I'm a win, mac or bsd fan, but whatever...) I temporarily gave up trying to actually get ahold of an old distro, so I tried the other

Re: Linux: How to statically link against system libs?

2011-05-08 Thread Nick Sabalausky
Nick Sabalausky a@a.a wrote in message news:iq60qt$pm0$1...@digitalmars.com... I downloaded 4.2 (picked pretty much at random), installed it in VirtualBox, compiled a trivial test C program in the included GCC, uploaded that to the server, and it worked! :) Actually, I did have to remove

Re: private module stuff

2011-05-08 Thread Sean Cavanaugh
On 5/8/2011 4:05 AM, Jonathan M Davis wrote: Sean Cavanaugh: So I was learning how to make a module of mine very strict with private parts, and was surprised I could only do this with global variables and functions. Enums, structs, and classes are fully visible outside the module

Re: Linux: How to statically link against system libs?

2011-05-08 Thread Spacen Jasset
On 08/05/2011 12:59, Nick Sabalausky wrote: Nick Sabalauskya@a.a wrote in message news:iq2g72$ngp$1...@digitalmars.com... Aggg!!! God damnnit, I officially fucking hate linux now... (not that I'm a win, mac or bsd fan, but whatever...) I temporarily gave up trying to actually get ahold

Re: private module stuff

2011-05-08 Thread bearophile
Sean Cavanaugh: With the language the way it is now, it is nonsensical to have the attributes public/protected/package/private/export precede the keyword struct, class, or enum. It's an implementation bug or a design bug. If it's not already in Bugzilla then it deserves to be there. Bye,

Re: Shouldn't duplicate functions be caught by DMD?

2011-05-08 Thread Stewart Gordon
On 08/05/2011 09:41, bearophile wrote: Andrej Mitrovic: I think the compiler should check catch these mistakes at compile-time. I suggest to add an enhancement request in Bugzilla. Bugzilla entries are a form of voting by themselves too. snip One should not file stuff in Bugzilla without

Re: int or size_t ?

2011-05-08 Thread Stewart Gordon
On 07/05/2011 18:09, %u wrote: In Patterns of Human Error, the slide 31 point that you should replce int with size_t why that consider an error ? For those who aren't sure what this is on about: http://www.slideshare.net/dcacm/patterns-of-human-error But the short answer is because dim is a

Re: Problem Passing Struct to C

2011-05-08 Thread Jacob Carlborg
On 2011-05-06 21:05, Robert Clipsham wrote: On 06/05/2011 19:40, Jacob Carlborg wrote: No, D implicitly casts string literals to zero-terminated const(char)*. That part is fine. -Steve Since when? Since const was introduced, before then they implicitly casted to char* instead. And that has

Re: Linux: How to statically link against system libs?

2011-05-08 Thread Jacob Carlborg
On 2011-04-29 22:02, Nick Sabalausky wrote: I'm having a rediculously hard time trying to find a CentOS 3 installation disc image (or any other version before 5.6). This is the closest I've been able to find: Have a look at this: http://vault.centos.org/ -- /Jacob Carlborg

Re: Getting equivalent elements in a range/array

2011-05-08 Thread Andrej Mitrovic
Thanks, group seems to work fine too.

Re: Cannot interpret struct at compile time

2011-05-08 Thread Lutger Blijdestijn
Robert Clipsham wrote: Hey all, I was wondering if anyone could enlighten me as to why the following code does not compile (dmd2, latest release or the beta): struct Foo { int a; } string test() { string str = struct ~ Foo.stringof ~ _{; foreach (j, f;

Re: Linux: How to statically link against system libs?

2011-05-08 Thread Adam D. Ruppe
Nick Sabalausky wrote: Actually, I did have to remove the HTTP status code output from my little hello world cgi test in forder for Apache to not throw up a 500. HTTP status is normally done with a Status: header in cgi. (Actually writing the line works too but only with certain settings.)

Re: Linux: How to statically link against system libs?

2011-05-08 Thread Nick Sabalausky
Adam D. Ruppe destructiona...@gmail.com wrote in message news:iq6osh$25di$1...@digitalmars.com... Nick Sabalausky wrote: Actually, I did have to remove the HTTP status code output from my little hello world cgi test in forder for Apache to not throw up a 500. HTTP status is normally done

Re: Linux: How to statically link against system libs?

2011-05-08 Thread Nick Sabalausky
Jacob Carlborg d...@me.com wrote in message news:iq6llk$20ch$1...@digitalmars.com... On 2011-05-08 19:50, Jacob Carlborg wrote: On 2011-04-29 22:02, Nick Sabalausky wrote: I'm having a rediculously hard time trying to find a CentOS 3 installation disc image (or any other version before 5.6).

Re: Linux: How to statically link against system libs?

2011-05-08 Thread Nick Sabalausky
Spacen Jasset spacenjas...@yahoo.co.uk wrote in message news:iq69q1$1ack$1...@digitalmars.com... It should work,but again is depends what your target platform is. It's quite important that - Even on windows. At the company I am now contracting for we compile the software agents using visual

Re: private module stuff

2011-05-08 Thread Jonathan M Davis
On 5/8/2011 4:05 AM, Jonathan M Davis wrote: Sean Cavanaugh: So I was learning how to make a module of mine very strict with private parts, and was surprised I could only do this with global variables and functions. Enums, structs, and classes are fully visible outside the

Re: Linux: How to statically link against system libs?

2011-05-08 Thread Spacen Jasset
On 08/05/2011 20:42, Nick Sabalausky wrote: Spacen Jassetspacenjas...@yahoo.co.uk wrote in message news:iq69q1$1ack$1...@digitalmars.com... It should work,but again is depends what your target platform is. It's quite important that - Even on windows. At the company I am now contracting for we

Re: Cannot interpret struct at compile time

2011-05-08 Thread Robert Clipsham
On 08/05/2011 19:19, Lutger Blijdestijn wrote: test also doesn't compile normally on my box, dmd errors on Foo.tupleof. Not sure if this is illegal or not. I think you want the allMembers trait or something similar. Something like this: import std.traits; string test(T)() { string str =

how to migrate to std.datetime

2011-05-08 Thread Adam D. Ruppe
I decided to update my compiler today, and regret it for a lot of reasons, but meh. One of the things is std.datetime. A lot of my code uses std.date. It works very, very well for me and I like it. But, the compile process is nagging me about it. I want it to shut up. However, I'm not even

Is there a better way to write this split functionality?

2011-05-08 Thread Andrej Mitrovic
import std.stdio; import std.array; import std.range; import std.algorithm; void main() { auto arr = [64, 64, 64, 32, 31, 16, 32, 33, 64]; auto newarr = arr[]; bool state = true; while (arr.length) { newarr = state ? array(until!(a 32)(arr))

Re: how to migrate to std.datetime

2011-05-08 Thread Jonathan M Davis
On 2011-05-08 17:46, Adam D. Ruppe wrote: I decided to update my compiler today, and regret it for a lot of reasons, but meh. One of the things is std.datetime. A lot of my code uses std.date. It works very, very well for me and I like it. But, the compile process is nagging me about it.

Re: how to migrate to std.datetime

2011-05-08 Thread Jonathan M Davis
I would point out though that'll be a while before std.date and its related functions actually go away, so any code which needs to be converted to std.datetime definitely has time to be reworked however is appropriate. Currently, they're scheduled for deprecation, which just results in the

Why does toUTF16z only work with UTF8 encoding?

2011-05-08 Thread Andrej Mitrovic
toUTF16 can take a char[], wchar[] or dchar[]. But toUTF16z can only take a char[]. Why? I'm storing some text as dchar[] internally and have to pass it to WinAPI Unicode functions which expect null-terminated UTF16 strings. But toUTF16z only works with char[] for some reason.

Re: Why does toUTF16z only work with UTF8 encoding?

2011-05-08 Thread Andrej Mitrovic
I guess this should do it: const(wchar)* toUTF16z(in dchar[] s) { return (toUTF16(s) ~ \000).ptr; }

Re: how to migrate to std.datetime

2011-05-08 Thread Adam D. Ruppe
Jonathan M Davis wrote: I would point out though that'll be a while before std.date and its related functions actually go away, so any code which needs to be converted to std.datetime definitely has time to be reworked however is appropriate. Yeah, but I figure it's better to do it sooner

Re: how to migrate to std.datetime

2011-05-08 Thread Jonathan M Davis
On 2011-05-08 21:29, Adam D. Ruppe wrote: Jonathan M Davis wrote: I would point out though that'll be a while before std.date and its related functions actually go away, so any code which needs to be converted to std.datetime definitely has time to be reworked however is appropriate.

Re: how to migrate to std.datetime

2011-05-08 Thread Nick Sabalausky
Jonathan M Davis jmdavisp...@gmx.com wrote in message news:mailman.74.1304905547.14074.digitalmars-d-le...@puremagic.com... On 2011-05-08 17:46, Adam D. Ruppe wrote: I decided to update my compiler today, and regret it for a lot of reasons, but meh. One of the things is std.datetime. A lot