Thread overview | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 22, 2008 Questions about D | ||||
---|---|---|---|---|
| ||||
Ive been learning c++ and was wondering if I should move over to D or not but theres a few details I'm not sure on and I couldn't find a good ansew on. 1)Is there a way to "hide" things complelty when building a static libary. eg in c++ if I have: //libary.h double GetRandomNumber(); //libary.cpp int DoSomething() { //do something } double GetRandomNumber() { return (double)rand() / RAND_MAX; } This is fine as the user doesn't know DoSomething() exists. But now if they create there own DoSomething() they get linker errors because it exists twice :( Also if I built a frame work based off of DirectX and Win32 API it's be nice to complelty hide functions from those unless the user imported them themselves. (So for them CreateWindow() doesn't exist UNLESS they imported the windows files themselves even though it's used in my libary) 2) I couldn't tell if D has an eqivlent to the STL. I can see that maps are built in but what of std::set and std::list? 3) How do I go about using DirectX with D as all the headers are c/c++ 4) Do the varible sizes work as in c or are they fixed? eg in c I could define them as char - at least one byte short - at least as large as a char int - at least as large as a short long - at least as large as an int But it would be nice if they were fixed eg char - 1 byte short - 2 bytes int - 4 bytes long - 8 bytes 5) |
May 22, 2008 Re: Questions about D | ||||
---|---|---|---|---|
| ||||
Posted in reply to FireLancer | FireLancer wrote: > Ive been learning c++ and was wondering if I should move over to D or not but theres a few details I'm not sure on and I couldn't find a good ansew on. > > 2) I > couldn't tell if D has an eqivlent to the STL. I can see that maps are > built in but what of std::set and std::list? Tango has a collection package. > 3) > How do I go about using DirectX with D as all the headers are c/c++ I would think there exists headers ported to D. > > 4) > Do the varible sizes work as in c or are they fixed? > eg in c I could define them as > > char - at least one byte > short - at least as large as a char > int - at least as large as a short > long - at least as large as an int > > But it would be nice if they were fixed eg > char - 1 byte > short - 2 bytes > int - 4 bytes > long - 8 bytes They are fixed with those sizes. -- Lars Ivar Igesund blog at http://larsivi.net DSource, #d.tango & #D: larsivi Dancing the Tango |
May 22, 2008 Re: Questions about D (DirectX) | ||||
---|---|---|---|---|
| ||||
Posted in reply to FireLancer | == Quote from FireLancer (FireLancer@yahoo.com)'s article ... > 3) > How do I go about using DirectX with D as all the headers are c/c++ I think there are a couple of D ports of the DirectX headers floating around. I suspect this is the best one (but I haven't used it myself): http://www.dsource.org/projects/bindings/browser/trunk/win32/directx (It's part of the "Windows API" project at dsource: http://www.dsource.org/projects/bindings/wiki/WindowsApi) |
May 22, 2008 Re: Questions about D | ||||
---|---|---|---|---|
| ||||
Posted in reply to FireLancer | FireLancer wrote:
> Ive been learning c++ and was wondering if I should move over to D or not but theres a few details I'm not sure on and I couldn't find a good ansew on.
>
> 1)Is there a way to "hide" things complelty when building a static libary. eg in c++ if I have:
>
> //libary.h
> double GetRandomNumber();
>
> //libary.cpp
> int DoSomething()
> {
> //do something
> }
> double GetRandomNumber()
> {
> return (double)rand() / RAND_MAX;
> }
>
>
> This is fine as the user doesn't know DoSomething() exists. But now if they create there own DoSomething() they get linker errors because it exists twice :(
Yes and no. In D, everything is qualified by its module name, and there's a 1:1 module:file correspondence. So it's unlikely that two modules would have the same fully-qualified name with the exact same symbol.
A bigger problem is that D doesn't have the concept of header files (well, it does sort of with .di files, but they're rarely used in open-source since they're generally not necessary if you have the source file). The problem is that if you import one of them, all the symbols (even those marked "private") will be imported.
|
May 22, 2008 Re: Questions about D (DirectX) | ||||
---|---|---|---|---|
| ||||
Posted in reply to jcc7 | jcc7 Wrote:
> == Quote from FireLancer (FireLancer@yahoo.com)'s article
> ...
>
> > 3)
> > How do I go about using DirectX with D as all the headers are c/c++
>
> I think there are a couple of D ports of the DirectX headers floating around. I suspect this is the best one (but I haven't used it myself): http://www.dsource.org/projects/bindings/browser/trunk/win32/directx
>
> (It's part of the "Windows API" project at dsource: http://www.dsource.org/projects/bindings/wiki/WindowsApi)
Is there no eqivlent of d3dx9.h or is it embedded in one of the other files? Ive used functions from that all over the place and I don't really want to relearn in order to work out ways of doing stuff without some of it's features and DirectX 10 isn't an option for me.
Also is there any support beyond Direct3D like DirectSound or xAudio2 (prefered) or will I need to write my own port of the March SDK to get those things?
|
May 22, 2008 Re: Questions about D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Fraser | Robert Fraser Wrote:
> FireLancer wrote:
> > Ive been learning c++ and was wondering if I should move over to D or not but theres a few details I'm not sure on and I couldn't find a good ansew on.
> >
> > 1)Is there a way to "hide" things complelty when building a static libary. eg in c++ if I have:
> >
> > //libary.h
> > double GetRandomNumber();
> >
> > //libary.cpp
> > int DoSomething()
> > {
> > //do something
> > }
> > double GetRandomNumber()
> > {
> > return (double)rand() / RAND_MAX;
> > }
> >
> >
> > This is fine as the user doesn't know DoSomething() exists. But now if they create there own DoSomething() they get linker errors because it exists twice :(
>
> Yes and no. In D, everything is qualified by its module name, and there's a 1:1 module:file correspondence. So it's unlikely that two modules would have the same fully-qualified name with the exact same symbol.
>
> A bigger problem is that D doesn't have the concept of header files (well, it does sort of with .di files, but they're rarely used in open-source since they're generally not necessary if you have the source file). The problem is that if you import one of them, all the symbols (even those marked "private") will be imported.
So like in c++ I can't choose not to export something in a static lib and make it completly unavaible?
|
May 22, 2008 Re: Questions about D | ||||
---|---|---|---|---|
| ||||
Posted in reply to FireLancer | FireLancer wrote:
> Robert Fraser Wrote:
>
>> FireLancer wrote:
>>> Ive been learning c++ and was wondering if I should move over to D or not but theres a few details I'm not sure on and I couldn't find a good ansew on.
>>>
>>> 1)Is there a way to "hide" things complelty when building a static libary. eg in c++ if I have:
>>>
>>> //libary.h
>>> double GetRandomNumber();
>>>
>>> //libary.cpp
>>> int DoSomething()
>>> {
>>> //do something
>>> }
>>> double GetRandomNumber()
>>> {
>>> return (double)rand() / RAND_MAX;
>>> }
>>>
>>>
>>> This is fine as the user doesn't know DoSomething() exists. But now if they create there own DoSomething() they get linker errors because it exists twice :(
>> Yes and no. In D, everything is qualified by its module name, and there's a 1:1 module:file correspondence. So it's unlikely that two modules would have the same fully-qualified name with the exact same symbol.
>>
>> A bigger problem is that D doesn't have the concept of header files (well, it does sort of with .di files, but they're rarely used in open-source since they're generally not necessary if you have the source file). The problem is that if you import one of them, all the symbols (even those marked "private") will be imported.
>
> So like in c++ I can't choose not to export something in a static lib and make it completly unavaible?
>
In C++ you can put things in an anonymous namespace:
namespace {
int variable_only_i_can_see;
double function_only_i_can_call() { return (double)rand()/RAND_MAX; }
}
In C you could use "static":
static int only_i_can_see;
In D I'm not sure if there is any such thing.
--bb
|
May 22, 2008 Re: Questions about D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bill Baxter | "Bill Baxter" <dnewsgroup@billbaxter.com> wrote in message news:g14nq9$dgq$1@digitalmars.com... > > In C++ you can put things in an anonymous namespace: > > namespace { > int variable_only_i_can_see; > double function_only_i_can_call() { return (double)rand()/RAND_MAX; } > } > > In C you could use "static": > > static int only_i_can_see; > > In D I'm not sure if there is any such thing. Uh, 'private'? |
May 22, 2008 Re: Questions about D | ||||
---|---|---|---|---|
| ||||
Posted in reply to FireLancer | OpenGL support is available via derelict, which is very ipressive package. I don't know about direct x. But if you are not fixed on the idea of direct x. Consider derelict, which also has joystick/sound support though the vorbis/ogg/sdl_mixer/sdl libraries. |
May 22, 2008 Re: Questions about D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote:
> "Bill Baxter" <dnewsgroup@billbaxter.com> wrote in message news:g14nq9$dgq$1@digitalmars.com...
>> In C++ you can put things in an anonymous namespace:
>>
>> namespace {
>> int variable_only_i_can_see;
>> double function_only_i_can_call() { return (double)rand()/RAND_MAX; }
>> }
>>
>> In C you could use "static":
>>
>> static int only_i_can_see;
>>
>> In D I'm not sure if there is any such thing.
>
> Uh, 'private'?
Maybe it's supposed to have that effect, but currently at least it does not insulate you from namespace clashes. Wasn't that how this conversation began?
--bb
|
Copyright © 1999-2021 by the D Language Foundation