Re: D1: UTF8 char[] casting to wchar[] array cast misalignment ERROR

2014-06-16 Thread Jacob Carlborg via Digitalmars-d-learn
On 17/06/14 04:27, jicman wrote: Greetings! I have a bunch of files plain ASCII, UTF8 and UTF16 with and without BOM (Byte Order Mark). I had, "I thought", a nice way of figuring out what type of encoding the file was (ASCII, UTF8 or UTF16) when the BOM was missing, by reading the content and

Re: what is going on with cgcs.c:351?

2014-06-16 Thread Vlad Levenfeld via Digitalmars-d-learn
I ran the program suggested by H.S. Teoh and the reduced code looks very similar #11763. I've submitted the bug at https://issues.dlang.org/show_bug.cgi?id=12926

Re: [Help]How to handle exception from dirEntries?

2014-06-16 Thread Keqin via Digitalmars-d-learn
Thanks for your reply! On Tuesday, 17 June 2014 at 04:50:43 UTC, Ali Çehreli wrote: On 06/16/2014 09:44 PM, Keqin wrote:> Hi everyone, > std.file.FileException@std\file.d(2519): C:\$Recycle.Bin\S-1-5-18: > Access is den > ied. > > I believe the exception comes from the following line: > auto en

Re: [Help]How to handle exception from dirEntries?

2014-06-16 Thread Ali Çehreli via Digitalmars-d-learn
On 06/16/2014 09:44 PM, Keqin wrote:> Hi everyone, > std.file.FileException@std\file.d(2519): C:\$Recycle.Bin\S-1-5-18: > Access is den > ied. > > I believe the exception comes from the following line: > auto entries = dirEntries(dirpath, SpanMode.depth); Known issue: https://issues.dlang.org

[Help]How to handle exception from dirEntries?

2014-06-16 Thread Keqin via Digitalmars-d-learn
Hi everyone, I have write a short program to check file size recursively as bellow. If i run this exe on windows eg.: hello.exe --dir C:\ It will throw as: std.file.FileException@std\file.d(2519): C:\$Recycle.Bin\S-1-5-18: Access is den ied. I believe the exception comes from the follow

Re: Trying to sort shared data with a predicate causes 'unable to format shared objects'

2014-06-16 Thread Ali Çehreli via Digitalmars-d-learn
On 06/16/2014 07:45 PM, George Sapkin wrote: I'm trying to sort shared data with a predicate. Buy that causes 'unable to format shared objects'. Here's an example reproducing the issue without any threading code: shared class SomeClass { immutable int value; this(const int value) {

Re: Placement of shared does not allow to set a delegate

2014-06-16 Thread Ali Çehreli via Digitalmars-d-learn
On 06/16/2014 09:37 AM, Tolga Cakiroglu wrote: > On Monday, 16 June 2014 at 15:25:51 UTC, Ali Çehreli wrote: > Okay, now I continue with another thing. After defining the event > attribute as follows > > public void delegate( shared(SocketListener) sender ) shared > eventWhenStarted; > > > --- >

Re: How to define and use a custom comparison function

2014-06-16 Thread Jakob Ovrum via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 04:32:20 UTC, Jakob Ovrum wrote: On Monday, 16 June 2014 at 20:49:29 UTC, monarch_dodra wrote: MyCompare cmp(SortOrder.ASC, 10); This syntax is not valid D. It should be: auto cmp = MyCompare(SortOrder,ASC, 10); Sorry, that first comma is a typo and should b

Re: How to define and use a custom comparison function

2014-06-16 Thread Jakob Ovrum via Digitalmars-d-learn
On Monday, 16 June 2014 at 20:49:29 UTC, monarch_dodra wrote: MyCompare cmp(SortOrder.ASC, 10); This syntax is not valid D. It should be: auto cmp = MyCompare(SortOrder,ASC, 10);

Trying to sort shared data with a predicate causes 'unable to format shared objects'

2014-06-16 Thread George Sapkin via Digitalmars-d-learn
I'm trying to sort shared data with a predicate. Buy that causes 'unable to format shared objects'. Here's an example reproducing the issue without any threading code: shared class SomeClass { immutable int value; this(const int value) { this.value = value; } } void main() {

D1: UTF8 char[] casting to wchar[] array cast misalignment ERROR

2014-06-16 Thread jicman via Digitalmars-d-learn
Greetings! I have a bunch of files plain ASCII, UTF8 and UTF16 with and without BOM (Byte Order Mark). I had, "I thought", a nice way of figuring out what type of encoding the file was (ASCII, UTF8 or UTF16) when the BOM was missing, by reading the content and applying the std.utf.validate

Re: Working on a library: request for code review

2014-06-16 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 16 June 2014 at 19:42:14 UTC, Mike wrote: I have refactored the code as recommended. I have also modified the not-yet-reviewed writers part to take advantage of the same approach (preallocated static-sized buffer) rather than allocate slices in loops. Hoping to hear something from

Re: Struct Constructors

2014-06-16 Thread Mark Blume via Digitalmars-d-learn
Adam, Dicebot, Thank you very much for the fast reply. I think this should be addressed at the documentation since it has ability to cause confusion for newbies like me.

Re: Struct Constructors

2014-06-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 16 June 2014 at 22:03:28 UTC, Mark Blume wrote: Why exactly isn't a constructor without any parameters is not allowed? The idea is that declaring a plain struct always has almost zero cost - it is just static data with no extra code run. A zero-arg constructor (aka a default constr

Re: Struct Constructors

2014-06-16 Thread Dicebot via Digitalmars-d-learn
On Monday, 16 June 2014 at 22:03:28 UTC, Mark Blume wrote: Why exactly isn't a constructor without any parameters is not allowed? Why does "Struct()" calls "Struct.opCall()," which means "Struct.init" initially, while "Struct(params)" calls "Struct.this(params)?" Does "Struct(params)" also ca

Struct Constructors

2014-06-16 Thread Mark Blume via Digitalmars-d-learn
Why exactly isn't a constructor without any parameters is not allowed? Why does "Struct()" calls "Struct.opCall()," which means "Struct.init" initially, while "Struct(params)" calls "Struct.this(params)?" Does "Struct(params)" also call "Struct.opCall(params)?" I am new to D and I can't seem

Re: Struct Constructors

2014-06-16 Thread Mark Blume via Digitalmars-d-learn
On Monday, 16 June 2014 at 22:03:28 UTC, Mark Blume wrote: Why exactly isn't a constructor without any parameters is not allowed? Why does "Struct()" calls "Struct.opCall()," which means "Struct.init" initially, while "Struct(params)" calls "Struct.this(params)?" Does "Struct(params)" also ca

Re: How to define and use a custom comparison function

2014-06-16 Thread monarch_dodra via Digitalmars-d-learn
On Monday, 16 June 2014 at 09:24:22 UTC, Marc Schütz wrote: You can pass anything to the sort function that's callable, including an object: struct MyCompare { SortOrder order; int column; bool opCall(const ref DataRow lhs, const ref DataRow rhs) { retu

Re: Working on a library: request for code review

2014-06-16 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 16 June 2014 at 19:42:14 UTC, Mike wrote: I have refactored the code as recommended. I have also modified the not-yet-reviewed writers part to take advantage of the same approach (preallocated static-sized buffer) rather than allocate slices in loops. Hoping to hear something from

Re: Working on a library: request for code review

2014-06-16 Thread Mike via Digitalmars-d-learn
I have refactored the code as recommended. I have also modified the not-yet-reviewed writers part to take advantage of the same approach (preallocated static-sized buffer) rather than allocate slices in loops. Hoping to hear something from you guys! Best, Mike

Re: Crash in byCodeUnit() <- byDchar() when converting faulty text to HTML

2014-06-16 Thread Nordlöw
AFAIK, no. You hit an Error, and those shouldn't occur unless you go out of your way for them. I'll look into it. Superb! What's there to say? They all take a range of characters, and return it as a range of the corresponding requested type. Excuse me for the kind of dumb question. I was u

Re: Doing exercise from book, but I'm getting error with splitter

2014-06-16 Thread Andrew Brown via Digitalmars-d-learn
I'm giving up On Monday, 16 June 2014 at 16:49:46 UTC, Andrew Brown wrote: Sorry, comments split over two lines, this should work: import std.stdio, std.array, std.string; //need to import std.array void main() { ulong[string] dictionary; // the length property is ulong, not uint forea

Re: Doing exercise from book, but I'm getting error with splitter

2014-06-16 Thread Andrew Brown via Digitalmars-d-learn
Sorry, comments split over two lines, this should work: import std.stdio, std.array, std.string; //need to import std.array void main() { ulong[string] dictionary; // the length property is ulong, not uint foreach (line; stdin.byLine()) { foreach (word; splitter(strip(line))) {

Re: Doing exercise from book, but I'm getting error with splitter

2014-06-16 Thread Andrew Brown via Digitalmars-d-learn
I think you can find splitter in std.array. I had a few other problems compiling your code, I could get this version to work: import std.stdio, std.array, std.string; //need to import std.array void main() { ulong[string] dictionary; // the length property is ulong, not uint foreach (line;

Re: Doing exercise from book, but I'm getting error with splitter

2014-06-16 Thread Sanios via Digitalmars-d-learn
On Monday, 16 June 2014 at 16:42:01 UTC, Brad Anderson wrote: On Monday, 16 June 2014 at 16:38:15 UTC, Sanios wrote: And I'm getting this - Error: undefined identifier splitter It seems like std.string doesn't contain splitter. You can find the solution to this and other issues you may hit

Re: Doing exercise from book, but I'm getting error with splitter

2014-06-16 Thread Sanios via Digitalmars-d-learn
Thanks, but getting another error. auto newID = dictionary.length; Error: associative arrays can only be assigned values with immutable keys, not char[]

Re: Doing exercise from book, but I'm getting error with splitter

2014-06-16 Thread Brad Anderson via Digitalmars-d-learn
On Monday, 16 June 2014 at 16:38:15 UTC, Sanios wrote: And I'm getting this - Error: undefined identifier splitter It seems like std.string doesn't contain splitter. You can find the solution to this and other issues you may hit in the errata: http://erdani.com/tdpl/errata/

Re: Placement of shared does not allow to set a delegate

2014-06-16 Thread Tolga Cakiroglu via Digitalmars-d-learn
On Monday, 16 June 2014 at 15:25:51 UTC, Ali Çehreli wrote: Here is a minimal example that reproduces the issue and the hint that compiles the code: class SocketListener { public void delegate( shared(SocketListener) sender ) /* shared */// <-- UNCOMMENT TO COMPILE eventWhenSt

Doing exercise from book, but I'm getting error with splitter

2014-06-16 Thread Sanios via Digitalmars-d-learn
Hello guys, as first I don't know, if I'm writing to correct section, but I've got a problem. I'm actually reading book of D guide and trying to do it like it is in book. My code is: import std.stdio, std.string; void main() { uint[string] dictionary; foreach (line; stdin.byLine

Re: Doing exercise from book, but I'm getting error with splitter

2014-06-16 Thread Tolga Cakiroglu via Digitalmars-d-learn
Add "import std.algorithm". Splitter is defined there. http://dlang.org/phobos/std_algorithm.html#splitter On Monday, 16 June 2014 at 16:38:15 UTC, Sanios wrote: Hello guys, as first I don't know, if I'm writing to correct section, but I've got a problem. I'm actually reading book of D guide and

Re: Placement of shared does not allow to set a delegate

2014-06-16 Thread Tolga Cakiroglu via Digitalmars-d-learn
Thanks Ali. That has solved the problem. Actually I tried to use that `shared` as follows before: public shared void delegate( shared(BasicSocketListener) sender ) eventWhenStarted; Though it didn't work with that. When it is put "before" the attribute name, it works now. It is just confusin

Re: what is going on with cgcs.c:351?

2014-06-16 Thread Kapps via Digitalmars-d-learn
Possibly https://issues.dlang.org/show_bug.cgi?id=11763 or https://issues.dlang.org/show_bug.cgi?id=11903

Re: Placement of shared does not allow to set a delegate

2014-06-16 Thread Ali Çehreli via Digitalmars-d-learn
On 06/16/2014 05:35 AM, Tolga Cakiroglu wrote:> In a class I defined an event attribute as follows: > > public void delegate( shared(SocketListener) sender ) eventWhenStarted; > > --- > > An instance of SocketListener is created. > > auto listener = new shared SocketListener(); > > --- > > I defi

Re: Crash in byCodeUnit() <- byDchar() when converting faulty text to HTML

2014-06-16 Thread monarch_dodra via Digitalmars-d-learn
On Monday, 16 June 2014 at 10:02:16 UTC, monarch_dodra wrote: I'll look into it. Yeah, there's an issue in the implementation. I brought it up in the pull page. If it doesn't get attention there, I'll file it.

Re: Is it normal that unittests of phobos are executed with my project build?

2014-06-16 Thread Dicebot via Digitalmars-d-learn
On Saturday, 14 June 2014 at 14:32:10 UTC, Xavier Bigand wrote: I get a failure on a test in format.d when I build my own project with unittest. I though importing phobos header would not regenerate their unittest modules. Any idea of what can cause this issue? I already have reinstalled dmd

Re: Is it normal that unittests of phobos are executed with my project build?

2014-06-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sat, 14 Jun 2014 10:32:04 -0400, Xavier Bigand wrote: I get a failure on a test in format.d when I build my own project with unittest. I though importing phobos header would not regenerate their unittest modules. Any idea of what can cause this issue? I already have reinstalled dmd

Placement of shared does not allow to set a delegate

2014-06-16 Thread Tolga Cakiroglu via Digitalmars-d-learn
In a class I defined an event attribute as follows: public void delegate( shared(SocketListener) sender ) eventWhenStarted; --- An instance of SocketListener is created. auto listener = new shared SocketListener(); --- I defined a shared method that will be called when the event occurs.

Re: Crash in byCodeUnit() <- byDchar() when converting faulty text to HTML

2014-06-16 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 15 June 2014 at 23:09:24 UTC, Nordlöw wrote: Is this intentional? utf.d on line 2703 is inside byCodeUnit(). AFAIK, no. You hit an Error, and those shouldn't occur unless you go out of your way for them. I'll look into it. When I use byChar() i doesn't crash but then I get incor

Re: How to define and use a custom comparison function

2014-06-16 Thread via Digitalmars-d-learn
You can pass anything to the sort function that's callable, including an object: struct MyCompare { SortOrder order; int column; bool opCall(const ref DataRow lhs, const ref DataRow rhs) { return order == SortOrder.ASC ? lhs[column] < rhs

Re: When is a slice not a slice?

2014-06-16 Thread Alix Pexton via Digitalmars-d-learn
On 06/06/2014 7:39 PM, Steven Schveighoffer wrote: On Fri, 06 Jun 2014 06:14:30 -0400, Rene Zwanenburg wrote: Immutables should be usable at compile time and not allocate a new instance on every use when in module scope. I was about to say this. But immutable can have its own set of issues. I

extern (C) Names & Signatures

2014-06-16 Thread Chris via Digitalmars-d-learn
I use a library written in C. There are these two functions 1. MyLib_Initialize(), an existing 3rd party function 2. my_lib_initialize(), my custom function On Linux (my main platform) it compiled and worked without an error. On Windows, however, implib printed a warning and said that two defi