Re: best idiom for insert if not present; else use value in assoc array

2013-02-08 Thread Andrej Mitrovic
On 2/7/13, Dan wrote: > I believe this would have to be done at the level of > AssociativeArray and can not be done as a helper function, since > this set helper is still doing 3 hashes/lookups. Feel free to file an enhancement request.

Re: search of a workaround

2013-02-08 Thread Namespace
On Friday, 8 February 2013 at 23:45:09 UTC, Namespace wrote: Thank you. But it looks ugly, and I dislike the use of such constructs for such simple feature. But cool thing. :D I like the meta stuff of D. :) Other favorites? Currently I think that Solutions #2 or Solution #5 are the best sol

Re: best idiom for insert if not present; else use value in assoc array

2013-02-08 Thread Ary Borenszweig
On 2/7/13 5:20 PM, Dan wrote: For an associative array, what is the best idiom that allows for checking if a key exists in the AA. If it does do something with the value, if not initialize the value and then do something with it. In this code: http://dpaste.dzfl.pl/daab318f How would this piece

Re: search of a workaround

2013-02-08 Thread Namespace
BTW: What's stopping you from using a class instead of a struct?

Re: search of a workaround

2013-02-08 Thread Namespace
Thank you. But it looks ugly, and I dislike the use of such constructs for such simple feature. But cool thing. :D I like the meta stuff of D. :) Other favorites?

Re: search of a workaround

2013-02-08 Thread monarch_dodra
On Friday, 8 February 2013 at 21:06:27 UTC, Namespace wrote: I've been thinking about the lack of rvalue references. Therefore, I would like to know what you think is the best workaround for this feature. I illustrate below the only (*) five solutions briefly and summarized. What do you think i

Re: Run program at startup

2013-02-08 Thread bearophile
rumbu: If you want D to become popular, that's not an appropiate answer in the d.learn section. I'm sure that if someone will ask the same thing in the C# section of MSDN will obtain an answer, not a redirect to an external forum. I agree that it's important to be gentle. (I remember the C

Re: Run program at startup

2013-02-08 Thread rumbu
On Friday, 8 February 2013 at 15:08:06 UTC, Dicebot wrote: On Friday, 8 February 2013 at 15:06:24 UTC, SaltySugar wrote: How to run my program when computer starts? This question is irrelevant to D and is operating system specific. It is better suited for stackoverflow & Co. If you want D t

Re: GC free Writer

2013-02-08 Thread David
> Does your IO layer require one call per log line or can you do multiple > writes followed by an "end log line" terminator? > Assuming the former, the most obvious approach would be for the writer to > have a static array equal to the max log line size, > accumulate until done and then issue on

Re: Rang violation using AA's

2013-02-08 Thread Nrgyzer
On Friday, 8 February 2013 at 20:30:00 UTC, Maxim Fomin wrote: On Friday, 8 February 2013 at 20:10:32 UTC, Nrgyzer wrote: void main() { int[string] b; b["hello"] = 3; } This works for both versions... but I don't know why using a method with ref-return value doesn't work anymore. Thanks

Re: GC free Writer

2013-02-08 Thread David
Am 08.02.2013 22:53, schrieb Lee Braiden: > On Fri, 08 Feb 2013 16:57:39 +0100, David wrote: >> I am currently implementing a logging module, I want to make logging to >> stderr/stdout/"any file" possible, also during runtime-shutdown (logging >> from dtors) >> >> Atm it lookes like this: >> >> ---

Re: GC free Writer

2013-02-08 Thread Lee Braiden
On Fri, 08 Feb 2013 16:57:39 +0100, David wrote: > I am currently implementing a logging module, I want to make logging to > stderr/stdout/"any file" possible, also during runtime-shutdown (logging > from dtors) > > Atm it lookes like this: > > > void log(LogLevel level, Args...)(Args args)

search of a workaround

2013-02-08 Thread Namespace
I've been thinking about the lack of rvalue references. Therefore, I would like to know what you think is the best workaround for this feature. I illustrate below the only (*) five solutions briefly and summarized. What do you think is the best? Which of these do you use? Or did I forget some p

Re: GC free Writer

2013-02-08 Thread Sean Kelly
On Feb 8, 2013, at 7:57 AM, David wrote: > I am currently implementing a logging module, I want to make logging to > stderr/stdout/"any file" possible, also during runtime-shutdown (logging > from dtors) > > Atm it lookes like this: > > > void log(LogLevel level, Args...)(Args args) { >

Re: Rang violation using AA's

2013-02-08 Thread Maxim Fomin
On Friday, 8 February 2013 at 20:10:32 UTC, Nrgyzer wrote: void main() { int[string] b; b["hello"] = 3; } This works for both versions... but I don't know why using a method with ref-return value doesn't work anymore. Thanks for your suggestion. This works because an element is assign

Re: what is special about unittest constants

2013-02-08 Thread anonymous
On Friday, 8 February 2013 at 20:12:41 UTC, Dan wrote: This constant in a module causes a compilation error of the "non-constant expression" variety. DEFINITION 1 const(AssetProjectionMap) SavingsGrowth2013 = [ AssetReturnType.Interest : RateCurve([DateRate(Date.min, CcRate(0.007))]),

what is special about unittest constants

2013-02-08 Thread Dan
This constant in a module causes a compilation error of the "non-constant expression" variety. DEFINITION 1 const(AssetProjectionMap) SavingsGrowth2013 = [ AssetReturnType.Interest : RateCurve([DateRate(Date.min, CcRate(0.007))]), ]; The fix that addresses this error at module level

Re: Rang violation using AA's

2013-02-08 Thread Nrgyzer
On Friday, 8 February 2013 at 19:24:55 UTC, simendsjo wrote: On Friday, 8 February 2013 at 17:16:15 UTC, Nrgyzer wrote: Hi guys, I'm updated from DMD 2.060 to 2.061 and I just run into some trouble by using associative arrays. Let's say I've the following few lines: string[string] myValues;

Re: Rang violation using AA's

2013-02-08 Thread simendsjo
On Friday, 8 February 2013 at 17:16:15 UTC, Nrgyzer wrote: Hi guys, I'm updated from DMD 2.060 to 2.061 and I just run into some trouble by using associative arrays. Let's say I've the following few lines: string[string] myValues; ref string getValue(string v) { return myValues[v]; } vo

Re: Alias parameter + AA + external module

2013-02-08 Thread Dicebot
Ok, can't find in bugzilla anything similar, have filed new one: http://d.puremagic.com/issues/show_bug.cgi?id=9486

Re: std.process.system and friends

2013-02-08 Thread Steven Schveighoffer
On Fri, 08 Feb 2013 04:17:02 -0500, Peter Sommerfeld wrote: Steven Schveighoffer schrieb: Windows is actually EXACTLY the same, except you don't use getenv and putenv, you use SetEnvironmentVariable and GetEnvironmentVariable. You can use the former if you want to use the C compatibility

Rang violation using AA's

2013-02-08 Thread Nrgyzer
Hi guys, I'm updated from DMD 2.060 to 2.061 and I just run into some trouble by using associative arrays. Let's say I've the following few lines: string[string] myValues; ref string getValue(string v) { return myValues[v]; } void main() { getValue("myValue") = "myString"; } I get a

Re: Alias parameter + AA + external module

2013-02-08 Thread monarch_dodra
On Friday, 8 February 2013 at 16:11:48 UTC, Dicebot wrote: On Friday, 8 February 2013 at 15:39:05 UTC, monarch_dodra wrote: Wait, this is giving me a compile error. You are getting a link error. What's going on? What compile error do you get? After removing exclamation mark from func declarat

Re: Alias parameter + AA + external module

2013-02-08 Thread Dicebot
On Friday, 8 February 2013 at 15:39:05 UTC, monarch_dodra wrote: Wait, this is giving me a compile error. You are getting a link error. What's going on? What compile error do you get? After removing exclamation mark from func declaration it works as described for me.

GC free Writer

2013-02-08 Thread David
I am currently implementing a logging module, I want to make logging to stderr/stdout/"any file" possible, also during runtime-shutdown (logging from dtors) Atm it lookes like this: void log(LogLevel level, Args...)(Args args) { string message = format(args); ... pass string to writ

Re: Alias parameter + AA + external module

2013-02-08 Thread monarch_dodra
On Friday, 8 February 2013 at 15:22:09 UTC, Dicebot wrote: On Friday, 8 February 2013 at 15:20:53 UTC, bearophile wrote: Dicebot: void func!(alias arr)() { arr["key"] = 43; } I think you have to remove that exclamation mark. Bye, bearophile Typo, irrelevant to subject. Wait, this is g

Re: Alias parameter + AA + external module

2013-02-08 Thread Dicebot
On Friday, 8 February 2013 at 15:20:53 UTC, bearophile wrote: Dicebot: void func!(alias arr)() { arr["key"] = 43; } I think you have to remove that exclamation mark. Bye, bearophile Typo, irrelevant to subject.

Re: Alias parameter + AA + external module

2013-02-08 Thread bearophile
Dicebot: void func!(alias arr)() { arr["key"] = 43; } I think you have to remove that exclamation mark. Bye, bearophile

Re: Run program at startup

2013-02-08 Thread Dicebot
On Friday, 8 February 2013 at 15:06:24 UTC, SaltySugar wrote: How to run my program when computer starts? This question is irrelevant to D and is operating system specific. It is better suited for stackoverflow & Co.

Alias parameter + AA + external module

2013-02-08 Thread Dicebot
== mod.d == void func!(alias arr)() { arr["key"] = 43; } == test.d == import mod; void main() { auto arr = [ "key" : 42 ]; func!(arr)(); } == shell == $ rdmd test.d .../test.o: In function `_D4test4mainFZv36__T4funcS24_D4test4mainFZv3arrHAyaiZ4funcMFZv': test.d:(.text._D4test4mainF

Re: How to read fastly files ( I/O operation)

2013-02-08 Thread monarch_dodra
On Friday, 8 February 2013 at 09:08:48 UTC, bioinfornatics wrote: And use size_t instead to int for getChar/getInt method as type returned gdmd -w -O -release monarch.d ~ $ time ./monarch /env/cns/proj/projet_AZH/A/RunsSolexa/121114_FLUOR_C16L5ACXX/AZH_AOSC_8_1_C16L5ACXX.IND1_clean.fastq glob

Re: make a nothrow call a throwing function

2013-02-08 Thread Ali Çehreli
On 02/08/2013 01:32 AM, Jonathan M Davis wrote: > On Friday, February 08, 2013 09:30:41 Artur Skawina wrote: >> On 02/08/13 01:33, Jonathan M Davis wrote: >>> Hmmm. I wouldn't have thought that you could get the function pointer at >>> compiler time. Regardless, you lose any possibility of inlin

Re: make a nothrow call a throwing function

2013-02-08 Thread monarch_dodra
On Friday, 8 February 2013 at 09:33:19 UTC, Jonathan M Davis wrote: On Friday, February 08, 2013 09:30:41 Artur Skawina wrote: On 02/08/13 01:33, Jonathan M Davis wrote: > Hmmm. I wouldn't have thought that you could get the > function pointer at > compiler time. Regardless, you lose any possib

Re: make a nothrow call a throwing function

2013-02-08 Thread Artur Skawina
On 02/08/13 10:32, Jonathan M Davis wrote: > On Friday, February 08, 2013 09:30:41 Artur Skawina wrote: >> On 02/08/13 01:33, Jonathan M Davis wrote: >>> Hmmm. I wouldn't have thought that you could get the function pointer at >>> compiler time. Regardless, you lose any possibility of inlining the

Re: make a nothrow call a throwing function

2013-02-08 Thread Jonathan M Davis
On Friday, February 08, 2013 09:30:41 Artur Skawina wrote: > On 02/08/13 01:33, Jonathan M Davis wrote: > > Hmmm. I wouldn't have thought that you could get the function pointer at > > compiler time. Regardless, you lose any possibility of inlining the > > function call, which is the main problem A

Re: std.process.system and friends

2013-02-08 Thread Peter Sommerfeld
Steven Schveighoffer schrieb: Windows is actually EXACTLY the same, except you don't use getenv and putenv, you use SetEnvironmentVariable and GetEnvironmentVariable. You can use the former if you want to use the C compatibility layer, but that's only if you use all compatibility layer func

Re: DWT with phobos on Windows

2013-02-08 Thread Jacob Carlborg
On 2013-02-08 00:41, deed wrote: Input regaridng DWT with phobos is welcome. See posting here: http://forum.dlang.org/thread/otyfilaasbxrwnqvr...@forum.dlang.org I've answered in the DWT newsgroup. -- /Jacob Carlborg

Re: make a nothrow call a throwing function

2013-02-08 Thread Artur Skawina
On 02/08/13 01:33, Jonathan M Davis wrote: > Hmmm. I wouldn't have thought that you could get the function pointer at > compiler time. Regardless, you lose any possibility of inlining the function > call, which is the main problem AFAIK, though I don't know if they would have > been an option in