View previous topic :: View next topic |
Author |
Message |
prefetch
Joined: 13 Aug 2005 Posts: 6
|
Posted: Mon Aug 15, 2005 8:03 am Post subject: std.math.pow brokeness |
|
|
D seems like a great language and all, but this seems broken to me. any ideas on why this doesn't work?
import std.math;
int main() {
int myint;
myint = pow(2,16);
}
rand.d(5): function std.math.pow called with argument types:
(int,int)
matches both:
std.math.pow(real,uint)
and:
std.math.pow(real,real)
rand.d(5): cannot implicitly convert expression (pow(2,16)) of type real to int |
|
Back to top |
|
|
jcc7
Joined: 22 Feb 2004 Posts: 657 Location: Muskogee, OK, USA
|
|
Back to top |
|
|
prefetch
Joined: 13 Aug 2005 Posts: 6
|
Posted: Mon Aug 15, 2005 12:01 pm Post subject: Re: std.math.pow brokeness |
|
|
thanks.
this is how it worked out:
import std.math;
int main() {
real myreal = pow(2.0L, cast(uint)3);
printf("?d\n",cast(int)myreal);
return 0;
}
let me complain a little bit here. this seems like an enormous amount of effort to print out what should be: printf("?d",pow(2,3));
what's up with this lameness? also, finding any reasonably good docs in this language is a nightmare. this is too bad, because i like the concepts of this language, but the docs just suck.
for example, i found some sample code with the function "Sleep" in it - but it wouldnt compile, so i started looking around for docs on the Sleep function. umm...still looking...
holy crap, shouldn't there be a freaking index of functions for the runtime lib? |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Mon Aug 15, 2005 2:16 pm Post subject: |
|
|
Your frustration is well-founded, I agree.
I'm pretty sure problems like this have been reported before. I suggest you go to the main d newsgroup and look through the posts there. If you can't find complaints/responses of a similar nature, make a post describing the issue on the bugs newsgroup.
Dsource is a good place for learning and connecting with other d developers, but it's not a effective medium for getting D language issues fixed (if that's your intention). You need to get the language designer's attention in that regard.
That said, I can sympathize with how you feel. That certainly looks to be silly phobos library issue.
-JJR |
|
Back to top |
|
|
pragma
Joined: 28 May 2004 Posts: 607 Location: Washington, DC
|
Posted: Mon Aug 15, 2005 5:15 pm Post subject: Re: std.math.pow brokeness |
|
|
prefetch wrote: | what's up with this lameness? also, finding any reasonably good docs in this language is a nightmare. this is too bad, because i like the concepts of this language, but the docs just suck.
for example, i found some sample code with the function "Sleep" in it - but it wouldnt compile, so i started looking around for docs on the Sleep function. umm...still looking...
holy crap, shouldn't there be a freaking index of functions for the runtime lib? |
I agree with you completely. I cringe every time I have to sift through the Phobos docs. Its obviously hurting D's adoption rate pretty badly.
If it helps, I think part of the problem is due to D being fostered broadly by hard-core hackers some of which have been working with D for years now; we're used to bad documentation and doing things the hard way. While this is no excuse, I think it explains the lack of negative feedback to Walter regarding the state of the DigitalMars D site.
I would *strongly* recommend putting your $0.02 up on the D news group, if you haven't already. There are some others who have set up external documentation sites, so you may likely find other D-philes who feel the same way (which will likely be everybody) with whom you can improve the situation.
Even though Walter has control of the language spec, and is developing the reference compiler, *everything else* is open. Since that's where his focus is, everything else imaginable comes a distant second with respect to the overall state of affairs. So its ultimately down to us to improve the state of D everywhere else that we can, through and beyond a 1.0 release. _________________ -- !Eric.t.Anderton at gmail |
|
Back to top |
|
|
Derek Parnell
Joined: 22 Apr 2004 Posts: 408 Location: Melbourne, Australia
|
Posted: Mon Aug 15, 2005 10:01 pm Post subject: Re: std.math.pow brokeness |
|
|
prefetch wrote: |
this is how it worked out:
import std.math;
int main() {
real myreal = pow(2.0L, cast(uint)3);
printf("?d\n",cast(int)myreal);
return 0;
}
let me complain a little bit here. this seems like an enormous amount of effort to print out what should be: printf("?d",pow(2,3));
|
This is how I would do it
Code: |
import std.math;
import std.stdio;
int main() {
writefln("?s", pow(2.0L,16U));
return 0;
}
|
prefetch wrote: | what's up with this lameness? also, finding any reasonably good docs in this language is a nightmare. this is too bad, because i like the concepts of this language, but the docs just suck.
for example, i found some sample code with the function "Sleep" in it - but it wouldnt compile, so i started looking around for docs on the Sleep function. umm...still looking...
holy crap, shouldn't there be a freaking index of functions for the runtime lib? |
Yep! The documentation is poor. _________________ --
Derek
skype name: derek.j.parnell |
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Mon Aug 15, 2005 10:27 pm Post subject: Re: std.math.pow brokeness |
|
|
prefetch wrote: |
for example, i found some sample code with the function "Sleep" in it - but it wouldnt compile, so i started looking around for docs on the Sleep function. umm...still looking... |
There is no Sleep function in D. I'm guessing that the code you refer to was from a Windows program and, if so, Sleep is a Win32 API function. Sleep halts execution of the current thread for the specified number of milliseconds. It is typically used to induce delays in program execution for one reason or another. Another common use is 'yielding' the time slice. If you look in the Phobos source for std.thread, you will see that the Thread.yield method is implemented as Sleep(0) on Windows, which effectively gives up the remainder of the current thread's time slice so that other threads (processes) can execute. |
|
Back to top |
|
|
prefetch
Joined: 13 Aug 2005 Posts: 6
|
Posted: Tue Aug 16, 2005 7:40 am Post subject: |
|
|
so i did a grep in the phobos 'source' and found sleep in time.d, and so that made me happier.
thanks for the feedback folks. i think i'll post a general "wtf" to the newsgroup (which has no search feature on it (at least the web one from the d site), so it's not very usable..)
i'll probably also post something about how broken the thread section of phobos seems to be as well. argh...i *really* want to use this language for a production system and have my engineering team learn it - but it's not making it easy.
btw - derek, thanks for the POW foo, that is much easier...of course, i'm not sure how i was supposed to divine that solution from the docs. it'd be nice to have that little sample you wrote in the phobos docs. |
|
Back to top |
|
|
sean
Joined: 24 Jun 2004 Posts: 609 Location: Bay Area, CA
|
Posted: Tue Aug 16, 2005 10:24 am Post subject: Re: std.math.pow brokeness |
|
|
aldacron wrote: | There is no Sleep function in D. I'm guessing that the code you refer to was from a Windows program and, if so, Sleep is a Win32 API function. Sleep halts execution of the current thread for the specified number of milliseconds. It is typically used to induce delays in program execution for one reason or another. Another common use is 'yielding' the time slice. If you look in the Phobos source for std.thread, you will see that the Thread.yield method is implemented as Sleep(0) on Windows, which effectively gives up the remainder of the current thread's time slice so that other threads (processes) can execute. |
std.thread should include a static 'sleep' function as well. Ares certainly has one. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|