I am just learning D, and playing around. So I have no good reason why one
would do the following, but I also don't understand why it doesn't work...
I was trying to make an associative array with int[5] as the value type. That
didn't work properly. int[] did, and I don't understand why.
Here is
Sorry, this could be a bug report and not a question, and probably the wrong
place to post it then.
I installed gdc according to the instructions given in
http://www.dsource.org/projects/tango/wiki/MacOSXInstall
from
http://sourceforge.net/project/downloading.php?group_id=135857&filename=gdc-tr
== Quote from Denis Koroskin (2kor...@gmail.com)'s article
> Bad installation, I suppose. 'string' is defined in Object.d, which is
> automatically imported in each
source file. Error is defined there, too. Looks like it can't find it. Make
sure it does exist and paths are
properly configured.
>
Jacob Carlborg Wrote:
> DFLAGS is working for me. I've placed dmd.conf in the same folder as
> dmd. Mac OS X doesn't have /etc by default.
That was the problem:
dmd.conf was copied to /usr/local/bin
The copy in /etc did nothing. The copy in /usr/local/bin was overriding any
DFLAGS I set.
And I
D is really great. I am trying to implement a medium sized project to get to
know it.
For this I need a sorted data structure, with cheap search, and somewhat cheap
forward and backward traversing.
I thought I should use tango (though it is a bit confusing that there is so
much overlap between
Steven Schveighoffer Wrote:
> On Tue, 21 Apr 2009 08:46:18 -0400, MLT wrote:
> dcollections+tango should do the trick for you. It is incidentally what I
> use (of course I wrote dcollections, so big surprise there ;)
>
Good! I just managed to compile my first program using 0
The fact that D has real typedef, not like the fake ones of C++ is, I think,
one of its great features.
But the fact that there is no automatic cast, together with typedef is causing
me problems.
The one I'm currently fighting with is initialization:
typedef long location ;
location a[] = [1,
Another question about typedef...
I am using
typedef long location ;
Now I would like to use tango.math.random.Random. But I am having problems with
calling r.uniformR( hi ) when r is a random genarator, and hi is of type
location.
I need to call
r.uniform!(long)( cast(long)(hi) ) ;
This is u
typedef long location ;
location a[] = cast(location[])[1,2,3,4] ;
Seems to work.
I was afraid of the mess that would happen if I cast (int *) to (long *) in C...
Can I trust it? Is that the "right way" to do it?
MLT Wrote:
> The fact that D has real typedef, not like the fake o
#x27; do some magic?
bearophile Wrote:
> MLT:
> > Is there a way to get the base type of location?
>
> See the BaseTypedef() template in the "templates" module of my dlibs (they
> are for Phobos):
> http://www.fantascienza.net/leonardo/so/libs_d.zip
>
> Bye,
> bearophile
Jarrett Billingsley Wrote:
> On Fri, May 1, 2009 at 9:15 AM, MLT wrote:
> >
> > typedef long location ;
> > location a[] = cast(location[])[1,2,3,4] ;
> >
> > Seems to work.
> > I was afraid of the mess that would happen if I cast (int *) to (long *) in
&
[] = a[]
doesn't seem to work...
Jarrett Billingsley Wrote:
> On Fri, May 1, 2009 at 10:07 AM, MLT wrote:
>
> > At first I thought that maybe on my machine int and long have the same
> > length, or some such. But it works, for int, long, and short. And they do
>
After a discussion on digitalmars.D I played with arrays a bit. Look at the
following code:
int[] a = [1,2,3,4,5,6,7,8,9] ;
int[] b = a ;
a ~= 10 ;
b ~= 11 ;
b[0] = 12 ;
Stdout(b).newline ;
Derek Parnell Wrote:
>
> So remember, assigning one array to another is just creating an alias to
> the original array. You end up with two arrays pointing to the same data
> buffer.
Yes. My question relates to what happens when you go beyond the bounds
originally assigned.
Why does an extensio
> Because new elements are pre-initialized in D.
>
> Just by increasing the length, you 'create' a new element (from the 'b'
> point of view) so D initializes it.
(We were talking about something like
int a[] = [1,2,3,4,5] ;
b = a ;
a ~= 6 ;
b.length = b.length+1;)
Hmmm... yes, that has some l
15 matches
Mail list logo