Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Allegro for the D programming language.

This thread is locked; no one can reply to it. rss feed Print
Allegro for the D programming language.
axilmar
Member #1,204
April 2001

If you are interested in the programming language D, the attachment contains whatever one needs to use Allegro from D.

From those who don't know, D is a new programming language which combines the best parts of C/C++ and Java. It can be found here:

www.digitalmars.com

23yrold3yrold
Member #1,134
March 2001
avatar

... attachment?

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

axilmar
Member #1,204
April 2001

It seems that it was eaten. Was it too large (758K) ? anyway, i am reposting it.

EDIT: indeed, too large. I've taken out the Allegro help and alleg40.dll (I wanted it to be complete for the D guys to download). Anyway, I hope it is ok now (83K).

X-G
Member #856
December 2000
avatar

The page said:

You can attach a small file (less than 500KB) to your post. It will not be displayed inline; only members will be able to download it. You should not select the file if you are spell checking or previewing.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Matthew Leverton
Supreme Loser
January 1999
avatar

It may be helpful to include a small bullet point list of how to set up the D environment, a simple Allegro hello world program, and a batch file that compiles it.

axilmar
Member #1,204
April 2001

Quote:

It may be helpful to include a small bullet point list of how to set up the D environment, a simple Allegro hello world program, and a batch file that compiles it.

Ok, here it is:

1) download the D compiler for WIN32 from here:

ftp://ftp.digitalmars.com/dmd.zip

2) download the D linker and utilities:

ftp://ftp.digitalmars.com/dmc.zip

3) unzip both packages at c:\.

4) download and install the D ide "DIDE" from here:

http://www.atari-soldiers.com/dide.html

5) set DIDE option Settings/DIDE settings/General Settings/DMD path to "C:\dmd\bin"

6) create a new project (option File/New Project). A hello world program will be created for you.

7) press F5 to compile and run the program.

8) read the D documentation from:

C:\dmd\html\d\index.html

Marco Radaelli
Member #3,028
December 2002
avatar

Which improvements may I get from learning and using D instead of C?

nonnus29
Member #2,606
August 2002
avatar

Quote:

Which improvements may I get from learning and using D instead of C?

You get to be a leet D-Dude?

axilmar
Member #1,204
April 2001

Quote:

Which improvements may I get from learning and using D instead of C?

-garbage collection
-no separation between header and implementation
-standard sizes of data types across different architectures
-no include files; uses import instead; results in much faster compiles
-templates and template specialization, either partial or complete (VC++ does not handle this correctly)
-class properties
-threads and synchronization
-unit tests
-design by contract
-asm
-direct interfacing to C
-no ->
-no ; after structs/classes

and lots of other things...

Generally, this language the best points of C/C++ and the best points of Java. You can code right to the metal, or as high level as Java.

Korval
Member #1,538
September 2001
avatar

Quote:

You can code right to the metal

Yeah. Except for that pesky memory management. No coding "right to the metal" there ::)

Chris Katko
Member #1,881
January 2002
avatar

Marco Radaelli said:

Which improvements may I get from learning and using D instead of C?

axilmar said:

-asm

Wait... since when does C/C++ not support assembly? Either inline or at link time?

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Korval
Member #1,538
September 2001
avatar

Speaking of which, how does C++ (let alone C itself) not offer "direct interfacing to C"?

X-G
Member #856
December 2000
avatar

What's "design by contract" supposed to be, by the way?

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

nonnus29
Member #2,606
August 2002
avatar

I hope axilmar doesn't get scared off, these are good questions. One of the problems with java is loading a binary file and mapping it to a struct; you can't do it. You have to load a byte array then step thru it and extract an int here, a float there etc... makes loading an MD2 file a pain the ass. So how does D deal with that?

spellcaster
Member #1,493
September 2001
avatar

Quote:

What's "design by contract" supposed to be, by the way?

Design by contract allows you to check the in and out values of a method. You could for example specify that a certain parameter has to be in a certain range, and that values returned have to be in another range.

If this is a language feature, automated testing gets way more easy, since the test routine can use the provided info to create test cases.
It's also some sort of additional documentation.

It's comparable to assert() on all invalid values for your function parameters in c - and then assert on your return values as well.
With the difference that the code to do this is created by the compiler.

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Oscar Giner
Member #2,207
April 2002
avatar

Quote:

What's "design by contract" supposed to be, by the way?

I've read it. It's similar to what the Eiffel language offers. You can implicitly define precondition, postconditions and bucle invariants. Preconditions and postconditions are inherited from the base class when you override a function. This info is also used by the compiler to make optimizations (lets say you say in the pre that the parameter i will be positive, maybe that leads to some optimization in some part of the code).

The tests to the pre/posts and invariants are also verified in debug builds, so they also act as ASSERT.

Here's a simple example in Eiffel:

set_type(type: INTEGER) is
require
  type = type_generic or
  type = type_terminal or
  type = type_out
do
  type_part := tipo;
ensure
  type_part = tipo
end

[edit]
It may seem that the last check is stupid. But it's not. If someone inherits from the class this method is in, that postcondition must be true also for the inherited class.

Paul Pridham
Member #250
April 2000
avatar

Quote:

Speaking of which, how does C++ (let alone C itself) not offer "direct interfacing to C"?

Name mangling.

extern "C" {
...
}

axilmar
Member #1,204
April 2001

Quote:

Yeah. Except for that pesky memory management. No coding "right to the metal" there

You have direct control of the garbage collector: you can remove objects from garbage collection anytime. You can also delete objects as in C/C++, manually, or overload the new and delete operations for custom memory management.

Quote:

Wait... since when does C/C++ not support assembly? Either inline or at link time?

Most C/C++ compilers do, but with D you have it right there as standard, and there is no variation in syntax between Linux and Windows.

Quote:

I hope axilmar doesn't get scared off

Not at all. My first reaction was "bah, C++ rules, I don't need another language". After a couple of weeks with D, I am at "C++ ? what C++ ?" :-)

Quote:

So how does D deal with that?

D provides unions and structs exactly like in C/C++, so you can load data and map them to structs directly. It also provides for user-controlled alignment of members.

Quote:

With the difference that the code to do this is created by the compiler.

Another benefit of the compiler handling contracts is that all those checks can be removed by a compiler switch.

Quote:

Speaking of which, how does C++ (let alone C itself) not offer "direct interfacing to C"?

This comment is mainly aimed at Java, which can't do direct interfacing. This makes it difficult to use already existing code written with C. With D, it's a child's play.

Evert
Member #794
November 2000
avatar

Quote:

there is no variation in syntax between Linux and Windows.

Nor is there with C.
There is difference in how things are handled by different compilers, but I can use the same inline assembler in Linux as in Windows.
I don't think it's much of a feature of a high-level language to have a standard way to inline assembler though, since assembler is by its very nature not portable and part of the rationale for using a high-level language is to hide the hardware specifics.

Quote:

Another benefit of the compiler handling contracts is that all those checks can be removed by a compiler switch.

Since assert isa a macro, this is true of C asserts as well. Not saying it's not a nifty language feature though.

spellcaster
Member #1,493
September 2001
avatar

I had a look at it, and it seems to be pretty neat. Not sure if I'm going to use it as my new language of choice, but I'll play with it a couple of weekends... it's a slick language.

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Chris Katko
Member #1,881
January 2002
avatar

Quote:

Nor is there with C.

Doesn't the GNU compiler use asm (no underscore?). MSVC uses _asm. And they both use different syntaxes (GNU is AT&T, MSVC is Intel).

Or are you comparing the two ports of the GNU compiler? In which case, I assume you'd be right.

Quote:

I don't think it's much of a feature of a high-level language to have a standard way to inline assembler though, since assembler is by its very nature not portable and part of the rationale for using a high-level language is to hide the hardware specifics.

Well, maybe it's whatever you want it to be. You could write very high level stuff, and have your renderer use very low level stuff, without having to use another language (excluding assembler, if you want it.) Leaving it up to smart people to make smart decisions, instead of forcing you do it their way. The one free of "potental" problems.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Evert
Member #794
November 2000
avatar

Quote:

Or are you comparing the two ports of the GNU compiler?

Yes. The difference between GCC and MSVC is just that, a difference between compilers, not platforms. The same inline code works in DOS, Windows and Linux, using gcc.

Go to: