Re: Struct constructor, opCall mess.

2014-02-24 Thread Maxim Fomin
On Monday, 24 February 2014 at 19:41:57 UTC, Remo wrote: For Vector example this works pretty well this way. But my main problem is more complicated. extern(C) int init(ref CWrapper p); extern(C) void free(ref CWrapper p); struct CWrapper { //some data that must be the same at C side. Data

Re: Struct constructor, opCall mess.

2014-02-24 Thread Tobias Pankrath
On Tuesday, 25 February 2014 at 06:06:22 UTC, Jesse Phillips wrote: On Monday, 24 February 2014 at 20:35:54 UTC, Remo wrote: This looks like D2 is still in Beta stadium and not really ready for production use !? If someone thinks that C++ was production ready in 1998, just go and try a C++ co

Re: What does q{...} mean?

2014-02-24 Thread Jesse Phillips
On Monday, 24 February 2014 at 18:40:14 UTC, monarch_dodra wrote: Also, a "qstring" can only contain valid D tokens ("token string"). If your mixin string does not adhere some the base D syntaxic rules, you'll get a compilation error. In particular, you'll need balanced bracing/parenthesising,

Re: Struct constructor, opCall mess.

2014-02-24 Thread Jesse Phillips
On Monday, 24 February 2014 at 20:35:54 UTC, Remo wrote: This looks like D2 is still in Beta stadium and not really ready for production use !? I believe it is ready for production, but you can't expect it to be ready in all cases. Mostly its lack of readiness isn't because of the language th

Re: Struct constructor, opCall mess.

2014-02-24 Thread Jesse Phillips
On Monday, 24 February 2014 at 23:34:51 UTC, Remo wrote: Where I can find more info about 'D's move semantics'? Apparently it is not the same as rvalue reference and move semantics in C++11 ? Here is the place I know of: http://dconf.org/2013/talks/cehreli.html

Re: Strange behaviour with -profile

2014-02-24 Thread Jesse Phillips
On Sunday, 23 February 2014 at 20:46:47 UTC, Jesse Phillips wrote: On Sunday, 23 February 2014 at 08:32:50 UTC, Danny Arends wrote: I have a medium sized project at: https://github.com/DannyArends/DaNode it compiles fine with the normal build switches I used: $ rdmd --build-only -O -gc -rel

Re: Struct constructor, opCall mess.

2014-02-24 Thread Remo
On Monday, 24 February 2014 at 21:06:03 UTC, monarch_dodra wrote: On Monday, 24 February 2014 at 17:15:10 UTC, Remo wrote: So what is proper/best way to mimic default constructor for struct ? Honestly, you can't, and you shouldn't try either. There "used" to be the static opCall that allowed:

Re: What does q{...} mean?

2014-02-24 Thread Dejan Lekic
Gary Willoughby wrote: > I keep seeing this syntax used a bit and i'm stumped to what it > means. What is it? > > enum foo = q{ > // ??? > }; q{} string literals (so-called "token strings") are a nice D feature - D garantees that tokens in between brackets are valid D tokens. This makes th

Re: Unused mmap library comes as deprecation warning on compile

2014-02-24 Thread Ali Çehreli
On 02/24/2014 12:20 PM, Tolga Cakiroglu wrote: > I have about 12 different separate programmes. While compiling only one > of them, it gives as warning as below: > > /usr/include/dmd/phobos/std/mmfile.d(344): Deprecation: alias > core.sys.posix.sys.mman.MAP_ANON is deprecated - Please use > core.

Re: Programming to Interfaces simplification

2014-02-24 Thread Steven Schveighoffer
On Mon, 24 Feb 2014 16:24:00 -0500, Frustrated wrote: On Monday, 24 February 2014 at 18:59:32 UTC, Steven Schveighoffer wrote: On Mon, 24 Feb 2014 11:36:50 -0500, Frustrated wrote: http://dpaste.dzfl.pl/c25655e2dfe9 The code above simplifies using interfaces as the programming object. It

Re: Parsing and splitting textfile

2014-02-24 Thread Justin Whear
On Mon, 24 Feb 2014 15:19:06 -0500, Hugo Florentino wrote: > On Mon, 24 Feb 2014 19:08:16 + (UTC), Justin Whear wrote: >> >> Specifically std.regex.splitter[1] creates a lazy range over the input. >> You can couple this with lazy file reading (e.g. >> `File("mailbox").byChunk (1024).joiner`).

Re: Programming to Interfaces simplification

2014-02-24 Thread Frustrated
Fixed code with all combination examples: (again, only WindowsButton works with WindowsGui and same for LinuxGui... but the classes don't use iButton like they should!!! Oh, they break the contract!! End of the world!) http://dpaste.dzfl.pl/02ee45225303 Output: Trying WindowsButton with Window

Re: Programming to Interfaces simplification

2014-02-24 Thread Frustrated
On Monday, 24 February 2014 at 18:59:32 UTC, Steven Schveighoffer wrote: On Mon, 24 Feb 2014 11:36:50 -0500, Frustrated wrote: http://dpaste.dzfl.pl/c25655e2dfe9 The code above simplifies using interfaces as the programming object. It allows one to program the derived classes as if they were

Re: Struct constructor, opCall mess.

2014-02-24 Thread monarch_dodra
On Monday, 24 February 2014 at 17:15:10 UTC, Remo wrote: So what is proper/best way to mimic default constructor for struct ? Honestly, you can't, and you shouldn't try either. There "used" to be the static opCall that allowed: auto a = T(); But: a) This is being phased out: If T h

Re: What does q{...} mean?

2014-02-24 Thread 1100110
On 2/24/14, 12:40, monarch_dodra wrote: Also, a "qstring" can only contain valid D tokens ("token string"). If your mixin string does not adhere some the base D syntaxic rules, you'll get a compilation error. In particular, you'll need balanced bracing/parenthesising, and correctly formed tokens

Re: Struct constructor, opCall mess.

2014-02-24 Thread Remo
Also please take a look at those: https://d.puremagic.com/issues/show_bug.cgi?id=7066 There may be some others I've missed; the sheer amount and unresolved state is terrifying. IMHO Issue 7066 is not a bug but a feature. Of course it could be handled i a bit more safe way. This looks like

Unused mmap library comes as deprecation warning on compile

2014-02-24 Thread Tolga Cakiroglu
I have about 12 different separate programmes. While compiling only one of them, it gives as warning as below: /usr/include/dmd/phobos/std/mmfile.d(344): Deprecation: alias core.sys.posix.sys.mman.MAP_ANON is deprecated - Please use core.sys.linux.sys.mman for non-POSIX extensions I used `g

Re: Parsing and splitting textfile

2014-02-24 Thread Hugo Florentino
On Mon, 24 Feb 2014 19:08:16 + (UTC), Justin Whear wrote: Specifically std.regex.splitter[1] creates a lazy range over the input. You can couple this with lazy file reading (e.g. `File("mailbox").byChunk (1024).joiner`). Would something like this work? (I cannot test it right now) aut

Re: Struct constructor, opCall mess.

2014-02-24 Thread Remo
Fortunately? Yes I think it is. Of course it could be made a more safe in some way. I think the big advantage of D is that it has 'bridge' to C and C++. This way it appears to be easy to port some C++ code to D. And it appears to be easy to interconnect C++ and D code. (via Dll for example)

Re: Parsing and splitting textfile

2014-02-24 Thread Steven Schveighoffer
On Mon, 24 Feb 2014 14:17:14 -0500, Hugo Florentino wrote: On Mon, 24 Feb 2014 14:00:09 -0500, Steven Schveighoffer wrote: std.regex I should have explained myself better. I have already used regular expressions a couple of times. My doubt here is how parse the file progressively, not loa

Re: Parsing and splitting textfile

2014-02-24 Thread Hugo Florentino
On Mon, 24 Feb 2014 19:08:16 + (UTC), Justin Whear wrote: Specifically std.regex.splitter[1] creates a lazy range over the input. You can couple this with lazy file reading (e.g. `File("mailbox").byChunk (1024).joiner`). Interesting, thanks.

Re: Parsing and splitting textfile

2014-02-24 Thread Hugo Florentino
On Mon, 24 Feb 2014 14:00:09 -0500, Steven Schveighoffer wrote: std.regex I should have explained myself better. I have already used regular expressions a couple of times. My doubt here is how parse the file progressively, not loading it completely into memory. If this can be done solely wi

Re: Parsing and splitting textfile

2014-02-24 Thread Justin Whear
On Mon, 24 Feb 2014 14:00:09 -0500, Steven Schveighoffer wrote: > On Mon, 24 Feb 2014 13:52:45 -0500, Hugo Florentino > wrote: > >> Hello, >> >> Can you point me to an efficient way to parse a text file and split it >> by certain expression (for example, `\n\nFrom\ .+@.+$`), copying what >> has

Re: Parsing and splitting textfile

2014-02-24 Thread Steven Schveighoffer
On Mon, 24 Feb 2014 13:52:45 -0500, Hugo Florentino wrote: Hello, Can you point me to an efficient way to parse a text file and split it by certain expression (for example, `\n\nFrom\ .+@.+$`), copying what has already been read to a separate file, and so on till the end of the file? I

Re: Programming to Interfaces simplification

2014-02-24 Thread Steven Schveighoffer
On Mon, 24 Feb 2014 11:36:50 -0500, Frustrated wrote: http://dpaste.dzfl.pl/c25655e2dfe9 The code above simplifies using interfaces as the programming object. It allows one to program the derived classes as if they were not part of an abstraction by mapping the abstracted virtual methods to co

Parsing and splitting textfile

2014-02-24 Thread Hugo Florentino
Hello, Can you point me to an efficient way to parse a text file and split it by certain expression (for example, `\n\nFrom\ .+@.+$`), copying what has already been read to a separate file, and so on till the end of the file? I am trying to implement a mailbox to maildir format conversion a

Re: Does opSlice work with immutable values?

2014-02-24 Thread anonymous
On Monday, 24 February 2014 at 17:11:20 UTC, Joseph Cassman wrote: The const/immutable language spec page states that mutable and immutable are implicitly convertible to const. Never thought about this in the other direction though. And from what I understand, the const keyword added to a funct

Re: What does q{...} mean?

2014-02-24 Thread monarch_dodra
On Monday, 24 February 2014 at 17:47:55 UTC, 1100110 wrote: On 2/24/14, 11:06, Gary Willoughby wrote: On Monday, 24 February 2014 at 11:53:00 UTC, anonymous wrote: On Monday, 24 February 2014 at 11:47:02 UTC, Namespace wrote: On Monday, 24 February 2014 at 11:41:41 UTC, Gary Willoughby wrote:

Re: Struct constructor, opCall mess.

2014-02-24 Thread Stanislav Blinov
On Monday, 24 February 2014 at 17:15:10 UTC, Remo wrote: Well fortunately it seems to be possible to override init property. Fortunately? I think not. It's an abomination that, IMO, has to be annihilated. Recently Andrei suggested adding more explicit semantics to .init that may give some le

Re: Does opSlice work with immutable values?

2014-02-24 Thread Joseph Cassman
On Monday, 24 February 2014 at 17:24:18 UTC, Ali Çehreli wrote: On 02/24/2014 09:11 AM, Joseph Cassman wrote: > the const keyword added to a [member] function makes the this pointer > const. Can't see exactly why this works but it does. const means "I will not modify data through this reference

Re: What does q{...} mean?

2014-02-24 Thread 1100110
On 2/24/14, 11:06, Gary Willoughby wrote: On Monday, 24 February 2014 at 11:53:00 UTC, anonymous wrote: On Monday, 24 February 2014 at 11:47:02 UTC, Namespace wrote: On Monday, 24 February 2014 at 11:41:41 UTC, Gary Willoughby wrote: I keep seeing this syntax used a bit and i'm stumped to what

Re: Does opSlice work with immutable values?

2014-02-24 Thread Ali Çehreli
On 02/24/2014 09:11 AM, Joseph Cassman wrote: > the const keyword added to a [member] function makes the this pointer > const. Can't see exactly why this works but it does. const means "I will not modify data through this reference". Since there is not issue with modification, it can refer to m

Re: Struct constructor, opCall mess.

2014-02-24 Thread Remo
On Monday, 24 February 2014 at 14:14:43 UTC, Tobias Pankrath wrote: On Monday, 24 February 2014 at 13:56:01 UTC, Remo wrote: Hi, right now I am truing to figure out how the constructors behave in D2. Question 1: why it is not possible to create custom ctor for struct? The design of D reli

Re: Does opSlice work with immutable values?

2014-02-24 Thread Joseph Cassman
On Monday, 24 February 2014 at 11:37:43 UTC, anonymous wrote: Mark opSlice const then. That did it. Thanks. The const/immutable language spec page states that mutable and immutable are implicitly convertible to const. Never thought about this in the other direction though. And from what I u

Re: What does q{...} mean?

2014-02-24 Thread Gary Willoughby
On Monday, 24 February 2014 at 11:53:00 UTC, anonymous wrote: On Monday, 24 February 2014 at 11:47:02 UTC, Namespace wrote: On Monday, 24 February 2014 at 11:41:41 UTC, Gary Willoughby wrote: I keep seeing this syntax used a bit and i'm stumped to what it means. What is it? enum foo = q{ //

Re: What does q{...} mean?

2014-02-24 Thread Philippe Sigaud
>>> On Monday, 24 February 2014 at 11:41:41 UTC, Gary Willoughby wrote: I keep seeing this syntax used a bit and i'm stumped to what it means. What is it? enum foo = q{ // ??? }; >> It's a token string though, not a delimited string. See the >> section "Token Strings" on

Programming to Interfaces simplification

2014-02-24 Thread Frustrated
http://dpaste.dzfl.pl/c25655e2dfe9 The code above simplifies using interfaces as the programming object. It allows one to program the derived classes as if they were not part of an abstraction by mapping the abstracted virtual methods to concrete methods. e.g., class WindowsGui : iGui {

Re: Non-Initialized Dynamic Arrays Construction

2014-02-24 Thread TheFlyingFiddle
On Monday, 24 February 2014 at 13:08:52 UTC, Mengu wrote: On Monday, 24 February 2014 at 11:29:39 UTC, bearophile wrote: TheFlyingFiddle: http://dlang.org/phobos/std_array.html#.uninitializedArray is what you want. The OP wants minimallyInitializedArray. uninitializedArray is only for speci

Re: Scalability in std.parallelism

2014-02-24 Thread Russel Winder
On Sun, 2014-02-23 at 22:55 -0800, Ali Çehreli wrote: […] > On my quad-core Intel I get the following (I have two actual cores, four > hyperthreads): > > 3.14159 took 441[ms] > 3.14159 took 878[ms] > Speedup 1.99093 > -5.80829e+09 took 98[ms] > -5.80829e+09 took 328[ms] > Speedup 3.34694 > > I a

Re: Scalability in std.parallelism

2014-02-24 Thread Russel Winder
On Sat, 2014-02-22 at 16:21 +, "Nordlöw" wrote: > In the following test code given below of std.parallelism I get > some interesting results: > > when compiled as > > dmd -release -noboundscheck -O -inline -w -wi -wi > ~/Work/justd/t_parallelism.d -oft_parallelism > > My scalability measu

Re: Struct constructor, opCall mess.

2014-02-24 Thread Tobias Pankrath
On Monday, 24 February 2014 at 13:56:01 UTC, Remo wrote: Hi, right now I am truing to figure out how the constructors behave in D2. Question 1: why it is not possible to create custom ctor for struct? The design of D relies on the fact that every type has a T.init property that is known t

Struct constructor, opCall mess.

2014-02-24 Thread Remo
Hi, right now I am truing to figure out how the constructors behave in D2. Question 1: why it is not possible to create custom ctor for struct? I know this is not really necessary because you can initialize fields like this. struct S{ int i = 1; } But this is a big problem if one tries to

Re: Non-Initialized Dynamic Arrays Construction

2014-02-24 Thread bearophile
Mengu: what's the difference? After you have read the online docs of both function what's your best guess of an answer? Bye, bearophile

Re: Non-Initialized Dynamic Arrays Construction

2014-02-24 Thread Mengu
On Monday, 24 February 2014 at 11:29:39 UTC, bearophile wrote: TheFlyingFiddle: http://dlang.org/phobos/std_array.html#.uninitializedArray is what you want. The OP wants minimallyInitializedArray. uninitializedArray is only for special situations. Perhaps we have to fix the online docs to u

Re: Non-Initialized Dynamic Arrays Construction

2014-02-24 Thread Andrej Mitrovic
On 2/24/14, bearophile wrote: > The OP wants minimallyInitializedArray. uninitializedArray is > only for special situations. There needs to be a ddoc-ed sample demonstrating *exactly* what the difference between minimallyInitializedArray and uninitializedArray is.

Re: Non-Initialized Dynamic Arrays Construction

2014-02-24 Thread Francesco Cattoglio
On Monday, 24 February 2014 at 12:08:31 UTC, Nordlöw wrote: On Monday, 24 February 2014 at 11:29:39 UTC, bearophile wrote: TheFlyingFiddle: http://dlang.org/phobos/std_array.html#.uninitializedArray is what you want. Wouldn't it be nice to have some kind of syntactic sugar for this similar

Re: Non-Initialized Dynamic Arrays Construction

2014-02-24 Thread simendsjo
On 02/24/2014 01:08 PM, "Nordlöw" wrote: On Monday, 24 February 2014 at 11:29:39 UTC, bearophile wrote: TheFlyingFiddle: http://dlang.org/phobos/std_array.html#.uninitializedArray is what you want. Wouldn't it be nice to have some kind of syntactic sugar for this similar to what we have for

Re: Non-Initialized Dynamic Arrays Construction

2014-02-24 Thread Nordlöw
On Monday, 24 February 2014 at 11:29:39 UTC, bearophile wrote: TheFlyingFiddle: http://dlang.org/phobos/std_array.html#.uninitializedArray is what you want. Wouldn't it be nice to have some kind of syntactic sugar for this similar to what we have for static arrays? BTW: Why isn't simply th

Re: What does q{...} mean?

2014-02-24 Thread Namespace
On Monday, 24 February 2014 at 11:53:00 UTC, anonymous wrote: On Monday, 24 February 2014 at 11:47:02 UTC, Namespace wrote: On Monday, 24 February 2014 at 11:41:41 UTC, Gary Willoughby wrote: I keep seeing this syntax used a bit and i'm stumped to what it means. What is it? enum foo = q{ //

Re: What does q{...} mean?

2014-02-24 Thread anonymous
On Monday, 24 February 2014 at 11:47:02 UTC, Namespace wrote: On Monday, 24 February 2014 at 11:41:41 UTC, Gary Willoughby wrote: I keep seeing this syntax used a bit and i'm stumped to what it means. What is it? enum foo = q{ // ??? }; http://dlang.org/lex.html#DelimitedString It's a to

Re: What does q{...} mean?

2014-02-24 Thread Namespace
On Monday, 24 February 2014 at 11:41:41 UTC, Gary Willoughby wrote: I keep seeing this syntax used a bit and i'm stumped to what it means. What is it? enum foo = q{ // ??? }; http://dlang.org/lex.html#DelimitedString

What does q{...} mean?

2014-02-24 Thread Gary Willoughby
I keep seeing this syntax used a bit and i'm stumped to what it means. What is it? enum foo = q{ // ??? };

Re: Does opSlice work with immutable values?

2014-02-24 Thread anonymous
On Monday, 24 February 2014 at 07:02:00 UTC, Joseph Cassman wrote: I have a custom number type in the works here (https://github.com/joichiro/kuttaka/commit/a226d3368a64ae63b0c256c4f4a4ede375a5cee8). The test code for opSlice works in this commit. However, when I change the auto to immutable (o

Re: Non-Initialized Dynamic Arrays Construction

2014-02-24 Thread bearophile
TheFlyingFiddle: http://dlang.org/phobos/std_array.html#.uninitializedArray is what you want. The OP wants minimallyInitializedArray. uninitializedArray is only for special situations. Perhaps we have to fix the online docs to underline this. Bye, bearophile

Re: Non-Initialized Dynamic Arrays Construction

2014-02-24 Thread TheFlyingFiddle
On Monday, 24 February 2014 at 11:11:44 UTC, Nordlöw wrote: Is it possible void construct a dynamic array such as b in int n = 3; auto b = new float[n]; similar to what we do with static arrays as in int[3] c = void; http://dlang.org/phobos/std_array.html#.uninitializedArray is

Non-Initialized Dynamic Arrays Construction

2014-02-24 Thread Nordlöw
Is it possible void construct a dynamic array such as b in int n = 3; auto b = new float[n]; similar to what we do with static arrays as in int[3] c = void;

Re: Scalability in std.parallelism

2014-02-24 Thread safety0ff
On Saturday, 22 February 2014 at 16:21:21 UTC, Nordlöw wrote: In the following test code given below of std.parallelism I get some interesting results: Don't forget that "n.iota.map" is returning a lazily evaluated range. Std.parallelism might have to convert the lazy range to a random access

Re: IFTI with value / template value parameter shadowing

2014-02-24 Thread Mathias LANG
On Sunday, 23 February 2014 at 11:49:26 UTC, Marc Schütz wrote: There's no IFTI here. IFTI is about inferring a template argument (= type) from the type of a function argument. Your template argument is a value, not a type, so there's nothing to infer. There is the value. In IFTI_Type, the co

Re: Scalability in std.parallelism

2014-02-24 Thread Per Nordlöw
I am not an expect at all but it looks like the first test cannot take advantage of hyperthreading but the second one can to some degree. Yes, that is my hypothesis aswell :) Thx

Re: Scalability in std.parallelism

2014-02-24 Thread Stanislav Blinov
Don't rely on dmd when making raw performance tests. On my machine (i3-2100, two cores): dmd2 -O -release -inline 3.14159 took 368[ms] 3.14159 took 713[ms] Speedup 1.9375 -5.80829e+09 took 61[ms] -5.80829e+09 took 201[ms] Speedup 3.29508 ldc2 -O3 -release 3.14159 took 360[ms] 3.14159 took 718