Re: array of constants?

2011-06-03 Thread Lloyd Dupont
thanks! "Etherous" wrote in message news:is8dbh$n22$1...@digitalmars.com... You need to set it in a static constructor immutable string[int] MyDict; static this () { MyDict = cast(string[int]) [ 1: "monday", 2: "tuesday" ]; }

.lib problem

2011-06-03 Thread Lloyd Dupont
what if the Win32 function I'm interested in don't seem to be in .lib provide by dmd... (for example vista & up windows function) Can I just use the .lib which come from the windows SDK?

Re: .lib problem

2011-06-03 Thread Andrej Mitrovic
If you have coffimplib (which isn't free), then you could just convert the windows sdk import lib to OMF format. Otherwise, you can create an import library from a DLL. Find the DLL (e.g. kernel32.dll), and run: implib /s kernel32.lib kernel32.dll Then link with the new import lib. I think that

very newbie question (sring confusion)

2011-06-03 Thread Lloyd Dupont
maybe it's late, or I have a hard time reading the string and array class methods.. (which I have! :~) anyway, I have a very simple problem and it seems hard to fix! let say I have a list of resource named preferential order (favored first) and I'd like to do return a list of match in preferent

Can't use float array in map

2011-06-03 Thread Andrej Mitrovic
test case: import std.algorithm; void main() { float[10] arr; arr[] = 0.0; map!((ref float sample){ sample = 1.0; })(arr[]); } D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(382): Error: nan is not an lvalue This looks like a bug to me?

Re: very newbie question (sring confusion)

2011-06-03 Thread Lloyd Dupont
I did the following, what do you think of my implementation? (checking if my string and array usage could be improved / powered up!!!) string[] _locales = ["en-AU", "fr-FR"]; string getCurrentLocal() { return "fr-BE"; } string[] getCandidates() { auto local = getCurrentLocal(); strin

Re: .lib problem

2011-06-03 Thread Lloyd Dupont
Thanks I'll try tomorrow! :) (now I should really go to bed...) "Andrej Mitrovic" wrote in message news:mailman.565.1307117174.14074.digitalmars-d-le...@puremagic.com... If you have coffimplib (which isn't free), then you could just convert the windows sdk import lib to OMF format. Otherwise

Re: Can't use float array in map

2011-06-03 Thread Andrej Mitrovic
Offending line in map: alias typeof(_fun(.ElementType!R.init)) ElementType; So it tires to pass .init which will be nan for floats. A quick workaround would be: static if (isFloatingPoint!(ElementType!R)) { .ElementType!R x; alias typeof(_fun(x)) ElementType; } els

Re: Can't use float array in map

2011-06-03 Thread Andrej Mitrovic
Ugh don't I love making silly posts like these. ref won't work for any types, not just floats, since it uses the .init property. My real problem was that I was using assignment in my first example instead of returning a value. Using map with ref doesn't make much sense. So my complaints are void.

Re: Can't use float array in map

2011-06-03 Thread bearophile
Andrej Mitrovic: > A quick workaround would be: > static if (isFloatingPoint!(ElementType!R)) > { > .ElementType!R x; > alias typeof(_fun(x)) ElementType; > } > else > { > alias typeof(_fun(.ElementType!R.init)) ElementType; > } If you have improvem

Re: Can't use float array in map

2011-06-03 Thread Ali Çehreli
On 06/03/2011 10:15 AM, Andrej Mitrovic wrote: > Offending line in map: > alias typeof(_fun(.ElementType!R.init)) ElementType; The fact that the error points at that line should be a bug. That's just an alias, nothing is evaluated at that line. Ali

Re: very newbie question (sring confusion)

2011-06-03 Thread bearophile
Lloyd Dupont: > I did the following, what do you think of my implementation? Those for loops seem better as foreach ones, or even reverse foreach ones. Probably in std.algorithm there is stuff to shorten your code. Bye, bearophile

Re: very newbie question (sring confusion)

2011-06-03 Thread Jonathan M Davis
On 2011-06-03 09:55, Lloyd Dupont wrote: > I did the following, what do you think of my implementation? > (checking if my string and array usage could be improved / powered > up!!!) > > string[] _locales = ["en-AU", "fr-FR"]; > string getCurrentLocal() { return "fr-BE"; } > string[] getCandida

Re: very newbie question (sring confusion)

2011-06-03 Thread Lloyd Dupont
std.algorithm! will have a look, thanks! "bearophile" wrote in message news:isb5ql$1i23$1...@digitalmars.com... Lloyd Dupont: I did the following, what do you think of my implementation? Those for loops seem better as foreach ones, or even reverse foreach ones. Probably in std.algorithm t

Re: .lib problem

2011-06-03 Thread Lloyd Dupont
Where can I find this "implib" tool you mentioned? I have the latest Windows SDK and Visual Studio 2010. Yet when I perform a search in program files I can't find it!! :( "Andrej Mitrovic" wrote in message news:mailman.565.1307117174.14074.digitalmars-d-le...@puremagic.com... If you have c

Re: .lib problem

2011-06-03 Thread Andrej Mitrovic
http://ftp.digitalmars.com/bup.zip Docs here: http://www.digitalmars.com/ctg/implib.html

Re: private method in interface

2011-06-03 Thread Michael Shulman
On Thu, Jun 2, 2011 at 11:55 PM, Jonathan M Davis wrote: > I don't really like the idea of private functions being virtual > by default though, so maybe your suggestion would be a good one. Speaking as a newbie with very little D experience, the idea of private functions being non-virtual would m

Re: private method in interface

2011-06-03 Thread Jonathan M Davis
On 2011-06-03 11:13, Michael Shulman wrote: > On Thu, Jun 2, 2011 at 11:55 PM, Jonathan M Davis wrote: > > I don't really like the idea of private functions being virtual > > by default though, so maybe your suggestion would be a good one. > > Speaking as a newbie with very little D experience,

Re: private method in interface

2011-06-03 Thread Michael Shulman
On Fri, Jun 3, 2011 at 11:22 AM, Jonathan M Davis wrote: >> However, given that in D, 'private' only means restricted to a >> *module*, it's less clear to me why private functions should be >> singled out as non-virtual. I might want certain methods to be >> accessible only within a given module,

Re: private method in interface

2011-06-03 Thread Jonathan M Davis
On 2011-06-03 11:59, Michael Shulman wrote: > On Fri, Jun 3, 2011 at 11:22 AM, Jonathan M Davis wrote: > >> However, given that in D, 'private' only means restricted to a > >> *module*, it's less clear to me why private functions should be > >> singled out as non-virtual. I might want certain met

Re: 16 byte alignment

2011-06-03 Thread Shahid
I made the Following change to backend/elfobj.c I have no idea what I just did but it has solved my problem Could anyone explain? -- align16.patch -- diff --u a/src/backend/elfobj.c b/src/backend/elfobj.c --- a/src/backend/elfobj.c +++ b/src/backend/elfobj.c @@ -683,7 +683,7 @@ void obj_init(Outb

Is this a good way of setting up a timer?

2011-06-03 Thread Andrej Mitrovic
I can't find any timers in phobos, basically I want some loop to run for a predetermined amount of time. Currently I use this: import core.time; import std.datetime; import core.thread; void main() { auto finalTime = Clock.currTime + dur!"seconds"(4); while (true) { Thre

Re: Is this a good way of setting up a timer?

2011-06-03 Thread Jonathan M Davis
On 2011-06-03 14:22, Andrej Mitrovic wrote: > I can't find any timers in phobos, basically I want some loop to run for a > predetermined amount of time. Currently I use this: > > import core.time; > import std.datetime; > import core.thread; > > void main() > { > auto finalTime = Clock.currTime +

Re: Is this a good way of setting up a timer?

2011-06-03 Thread Andrej Mitrovic
On 6/3/11, Jonathan M Davis wrote: > > Generally, you'd just put it to sleep for the period of time that you want > to > wait for. The only reason that I see to keep waking it up is if it could be > interrupted and effectively told to wake up - in which case you would be > sleeping and waking up o

Re: private method in interface

2011-06-03 Thread Michael Shulman
On Fri, Jun 3, 2011 at 1:02 PM, Jonathan M Davis wrote: > And if you don't know about NVI, having a > virtual private function is just plain weird. Well, it makes perfect sense to me, once given that in D, 'private' allows access from anywhere in the same module, rather than only in the defining

Re: Is this a good way of setting up a timer?

2011-06-03 Thread Jonathan M Davis
On 2011-06-03 14:37, Andrej Mitrovic wrote: > On 6/3/11, Jonathan M Davis wrote: > > Generally, you'd just put it to sleep for the period of time that you > > want to > > wait for. The only reason that I see to keep waking it up is if it could > > be interrupted and effectively told to wake up - i

Re: Is this a good way of setting up a timer?

2011-06-03 Thread Andrej Mitrovic
I didn't even think about issue #1. Thanks again!

Re: private method in interface

2011-06-03 Thread Jonathan M Davis
On 2011-06-03 14:55, Michael Shulman wrote: > On Fri, Jun 3, 2011 at 1:02 PM, Jonathan M Davis wrote: > > And if you don't know about NVI, having a > > virtual private function is just plain weird. > > Well, it makes perfect sense to me, once given that in D, 'private' > allows access from anywh

Re: .lib problem

2011-06-03 Thread Lloyd Dupont
Sweet, thanks you very much! :) "Andrej Mitrovic" wrote in message news:mailman.573.1307123755.14074.digitalmars-d-le...@puremagic.com... http://ftp.digitalmars.com/bup.zip Docs here: http://www.digitalmars.com/ctg/implib.html

Re: private method in interface

2011-06-03 Thread Michael Shulman
On Fri, Jun 3, 2011 at 3:07 PM, Jonathan M Davis wrote: > I'd suggest opening a bug report. Okay, will do. > Regardless, I would have hoped that you'd get an error at compile > time about overriding a non-virtual function if package is > non-virtual It appears that overriding a non-virtual, non

Re: private method in interface

2011-06-03 Thread Michael Shulman
The bug report appears to already exist: http://d.puremagic.com/issues/show_bug.cgi?id=3258 On Fri, Jun 3, 2011 at 3:07 PM, Jonathan M Davis wrote: > On 2011-06-03 14:55, Michael Shulman wrote: >> On Fri, Jun 3, 2011 at 1:02 PM, Jonathan M Davis > wrote: >> > And if you don't know about NVI, hav

Re: private method in interface

2011-06-03 Thread Jonathan M Davis
On 2011-06-03 19:44, Michael Shulman wrote: > On Fri, Jun 3, 2011 at 3:07 PM, Jonathan M Davis wrote: > > I'd suggest opening a bug report. > > Okay, will do. > > > Regardless, I would have hoped that you'd get an error at compile > > time about overriding a non-virtual function if package is >

Re: private method in interface

2011-06-03 Thread Michael Shulman
On Fri, Jun 3, 2011 at 8:54 PM, Jonathan M Davis wrote: > Try to compile with -w. My guess is that you will get a compiler error. Nope.

Re: private method in interface

2011-06-03 Thread Jonathan M Davis
On 2011-06-03 21:52, Michael Shulman wrote: > On Fri, Jun 3, 2011 at 8:54 PM, Jonathan M Davis wrote: > > Try to compile with -w. My guess is that you will get a compiler error. > > Nope. Then file a bug report on it. As I understand it, overriding a non-virtual function in D should be illegal