Re: Is it possible to handle 'magic' property assignments a'la PHP?

2014-01-09 Thread Jacob Carlborg
On 2014-01-08 19:04, H. S. Teoh wrote: The reason I wrote it this way is so that it parallels the foreach construction better: my_foreach (i; range) { ... } parallels: foreach (i; range) { ... } I guessed that. Keep in mind t

Re: Study on hash associative arrays

2014-01-09 Thread Ola Fosheim Grøstad
On Thursday, 9 January 2014 at 10:48:22 UTC, bearophile wrote: Through Reddit I've found posts about hash-based associative arrays: http://bannalia.blogspot.it/2013/10/implementation-of-c-unordered.html I think the worry that a hash function should throw an exception is a bit over the top? W

Properties and std.container.Array

2014-01-09 Thread Frustrated
I've tried insert, indexing, ~=, etc but the length always returns 0. e.g., std.container.Array!int arr; arr ~= 3; writeln(arr.length); works fine, but when the array is a property of a class, it does not work, e.g., class x { std.container.Array!int _arr; @property std.container.Array!int

Re: Properties and std.container.Array

2014-01-09 Thread Frustrated
On Thursday, 9 January 2014 at 12:13:14 UTC, Frustrated wrote: I've tried insert, indexing, ~=, etc but the length always returns 0. e.g., std.container.Array!int arr; arr ~= 3; writeln(arr.length); works fine, but when the array is a property of a class, it does not work, e.g., class x {

Re: Properties and std.container.Array

2014-01-09 Thread Frustrated
On Thursday, 9 January 2014 at 12:15:31 UTC, Frustrated wrote: On Thursday, 9 January 2014 at 12:13:14 UTC, Frustrated wrote: I've tried insert, indexing, ~=, etc but the length always returns 0. e.g., std.container.Array!int arr; arr ~= 3; writeln(arr.length); works fine, but when the array

Re: Simplest way to create an array from an associative array which its contains keys and values?

2014-01-09 Thread bearophile
string[] r = aa.byKey.map!(k => [k, aa[k]]s).join; Do you remember the bug report number and/or pull request number for that enhancement? Bye, bearophile

Re: Properties and std.container.Array

2014-01-09 Thread Dicebot
On Thursday, 9 January 2014 at 12:19:25 UTC, Frustrated wrote: I guess I see what is going on. Since Array is a struct, a local copy is made and that never ends up updating the original? How can I use it then like an object so this is not a problem? returning by ref may do what you want: @pr

Re: Properties and std.container.Array

2014-01-09 Thread monarch_dodra
On Thursday, 9 January 2014 at 13:32:08 UTC, Dicebot wrote: On Thursday, 9 January 2014 at 12:19:25 UTC, Frustrated wrote: I guess I see what is going on. Since Array is a struct, a local copy is made and that never ends up updating the original? How can I use it then like an object so this i

Re: Is it possible to handle 'magic' property assignments a'la PHP?

2014-01-09 Thread H. S. Teoh
On Thu, Jan 09, 2014 at 09:49:17AM +0100, Jacob Carlborg wrote: > On 2014-01-08 19:04, H. S. Teoh wrote: [...] > >In fact, we can already almost get the desired syntax in the current > >language: > > > > /* Current D already supports this: */ > > range.my_foreach!((i,j) { > > /*

Re: Study on hash associative arrays

2014-01-09 Thread Benjamin Thaut
Am 09.01.2014 11:48, schrieb bearophile: Through Reddit I've found posts about hash-based associative arrays: http://bannalia.blogspot.it/2013/10/implementation-of-c-unordered.html http://bannalia.blogspot.it/2014/01/a-better-hash-table.html Those little images like this one are excellent at ex

Thread Building Blocks

2014-01-09 Thread Ross Hays
Does anybody know if there is a library like thread building blocks for D? I imagine that it hasn't been ported or anything given it is a C++ library and licensed inconveniently. If not, is there something in Phobos similar to it or that would help in making it? I may try writing something lik

Re: Thread Building Blocks

2014-01-09 Thread Kelet
On Thursday, 9 January 2014 at 19:15:50 UTC, Ross Hays wrote: Does anybody know if there is a library like thread building blocks for D? I imagine that it hasn't been ported or anything given it is a C++ library and licensed inconveniently. If not, is there something in Phobos similar to it or

Re: Getting backtrace

2014-01-09 Thread Xavier Bigand
Le 08/01/2014 21:29, Benjamin Thaut a écrit : Am 08.01.2014 21:25, schrieb Xavier Bigand: Is there a way to get backtrace outside exceptions? Found a plattform independend way: import core.runtime; import std.stdio; void main(string[] args) { auto trace = defaultTraceHandler(null);

Re: Is it possible to handle 'magic' property assignments a'la PHP?

2014-01-09 Thread Jacob Carlborg
On 2014-01-09 18:57, H. S. Teoh wrote: I'm afraid that this might become ambiguous, for example: int* gun(...) {...} func (x==0) *gun(y); Does the second statement mean `func!(() => *gun(y))(x==0)`, or does it mean `func(x==0) * gun(y)`? While it's not hard to

deh_beg and deh_end linker error

2014-01-09 Thread tivadj
Hi all, Well, the original post was long time ago, but I have a similar problem now. I am linking static D library into C++ executable and getting linker errors Phobos64.lib(sections_win64_4f1_4e2.obj) : error LNK2019 : unresolved external symbol _deh_beg referenced in function _D2rt14secti

Re: Properties and std.container.Array

2014-01-09 Thread Frustrated
On Thursday, 9 January 2014 at 14:51:33 UTC, monarch_dodra wrote: On Thursday, 9 January 2014 at 13:32:08 UTC, Dicebot wrote: On Thursday, 9 January 2014 at 12:19:25 UTC, Frustrated wrote: I guess I see what is going on. Since Array is a struct, a local copy is made and that never ends up updat

Re: Properties and std.container.Array

2014-01-09 Thread Frustrated
I think maybe using alias this would not solve the problem? One would have to dispatch all the calls on the class to the array. (simply wrap the struct but prevent the compiler from thinking it is a strut so it doesn't use value semantics on it)

singleton with "momento"

2014-01-09 Thread Frustrated
Lets suppose I have setup some code to use a singleton object. Now lets suppose I want to duplicate that code(say to run multiple times simultaneously). The singleton pattern itself prevents multiple copies. One would need multiple instances to be able to run multiple times BUT in the context

Re: Learning D as main systems programming language

2014-01-09 Thread qznc
On Wednesday, 8 January 2014 at 23:38:31 UTC, Goran Petrevski wrote: I'm new in the programming, systems programming especially, but I want to learn D more as a systems programming language and by that I mean avoiding libraries at all. My goal is to write a simple operating system totaly in D (

Re: Pure

2014-01-09 Thread Ola Fosheim Grøstad
On Wednesday, 8 January 2014 at 21:37:24 UTC, Ali Çehreli wrote: On 01/08/2014 11:39 AM, "Ola Fosheim Grøstad" > So, "saflik" is "pure" in turkish, cool! I like the sound of it. 8-D It is never easy, is it? :) The reason it is "saflik" in the URL is because file names better be in ASCII due to

std.xml

2014-01-09 Thread Ola Fosheim Grøstad
The std.xml documentation states "This module is considered out-dated and not up to Phobos' current standards." Does this mean that there is some other module I should use for xml parsing? Maybe one that is not in the standard distribution yet because it is beta? I'd like to convert a xml-ba

Re: Learning D as main systems programming language

2014-01-09 Thread Goran Petrevski
You might want to look into XOmB: https://github.com/xomboverlord/xomb Isn't it written in D1? Not sure about that...

BitArray oddities

2014-01-09 Thread Adam S
Playing around with BitArray I encountered the seemingly strange interface of --- bool[] b = [0, 1, 0]; BitArray a; a.init(b); --- Is there any reason 'init' is used rather than using a constructor? bool[] b = [0, 1, 0]; BitArray a = BitArray(b); Seems a bit cl

Re: BitArray oddities

2014-01-09 Thread Adam D. Ruppe
On Friday, 10 January 2014 at 02:08:21 UTC, Adam S wrote: Can anyone explain the reason for this setup? BitArray was mostly written back in the D1 days, before structs were allowed to have constructors. It got partially updated, but the majority of its code is still an old style. I recently

Re: std.xml

2014-01-09 Thread Jacob Carlborg
On 2014-01-10 01:02, "Ola Fosheim Grøstad" " wrote: The std.xml documentation states "This module is considered out-dated and not up to Phobos' current standards." Does this mean that there is some other module I should use for xml parsing? Maybe one that is not in the standard distribution yet