www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - DMD 0.145 release

reply "Walter Bright" <newshound digitalmars.com> writes:
Lots of bugs fixed. -fPIC code gen fixes, should be a big step towards 
shared library support under Linux.

http://www.digitalmars.com/d/changelog.html
Jan 29 2006
next sibling parent John Reimer <terminal.node gmail.com> writes:
Walter Bright wrote:
 Lots of bugs fixed. -fPIC code gen fixes, should be a big step towards 
 shared library support under Linux.
 
 http://www.digitalmars.com/d/changelog.html
 
Nice update, Walter. Thanks again. I liked this particularly:
 Fixed several problems with -fPIC code generation
:) -JJR
Jan 29 2006
prev sibling next sibling parent reply Don Clugston <dac nospam.com.au> writes:
Walter Bright wrote:
 Lots of bugs fixed. -fPIC code gen fixes, should be a big step towards 
 shared library support under Linux.
 
 http://www.digitalmars.com/d/changelog.html
And as a result of the template bug fixes, this is now possible: -------------------------------------- // Create a constant array of int or uint sized items // as a dchar[] string. n is the index of the last item. template makeLookup(alias entry, int n) { static if (n == -1) // start with an empty array... const dchar [] makeLookup = ""; else // ... and fill it up const dchar [] makeLookup = makeLookup!(entry, n-1) ~ cast(dchar)entry!(n); } // only needed to workaround a DMD 0.145 bug template LookupTable(alias entry, int n) { const LookupTable = cast(typeof(entry!(0)) [])makeLookup!(entry, n); } // USAGE: Let's make a factorial lookup table template factorial(uint n) { static if (n<2) const uint factorial = 1; else const factorial = n * factorial!(n-1); } // Make an array of all the factorials from 0 to 13 (14!> uint.max) const smallfactorials = LookupTable!(factorial, 13); import std.stdio; void main() { for (int i=0; i<smallfactorials.length; ++i) writefln(i, " ", smallfactorials[i]); } -------------------------------------- I've wanted to do this in C++ for a very long time. I thought that we would need array literals to be able to do this. Apparently not. Also note the extensive use of type inference! If there was some way at compile time of doing a reinterpret_cast() from any type to an array of bytes, the LookupTable function could be made to work for ANY type whatsoever, with negligible increase in complexity. (just need to change cast(dchar) to something like reinterpret_cast(char[])). But, I even wonder if could be made to work without any casts at all. I can see that array literals are difficult in the general case. But here, all of the types are known. Would it be possible to do constant folding on arbitrary arrays, even before array literals are implemented?
Jan 30 2006
parent reply John Reimer <terminal.node gmail.com> writes:
Don Clugston wrote:
 Walter Bright wrote:
 Lots of bugs fixed. -fPIC code gen fixes, should be a big step towards 
 shared library support under Linux.

 http://www.digitalmars.com/d/changelog.html
And as a result of the template bug fixes, this is now possible: -------------------------------------- // Create a constant array of int or uint sized items // as a dchar[] string. n is the index of the last item. template makeLookup(alias entry, int n) { static if (n == -1) // start with an empty array... const dchar [] makeLookup = ""; else // ... and fill it up const dchar [] makeLookup = makeLookup!(entry, n-1) ~ cast(dchar)entry!(n); } // only needed to workaround a DMD 0.145 bug template LookupTable(alias entry, int n) { const LookupTable = cast(typeof(entry!(0)) [])makeLookup!(entry, n); } // USAGE: Let's make a factorial lookup table template factorial(uint n) { static if (n<2) const uint factorial = 1; else const factorial = n * factorial!(n-1); } // Make an array of all the factorials from 0 to 13 (14!> uint.max) const smallfactorials = LookupTable!(factorial, 13); import std.stdio; void main() { for (int i=0; i<smallfactorials.length; ++i) writefln(i, " ", smallfactorials[i]); }
Fascinating... I had to look at that for awhile to figure out what you were up to! -JJR
Jan 30 2006
parent James Dunne <james.jdunne gmail.com> writes:
John Reimer wrote:
 Don Clugston wrote:
 
 Walter Bright wrote:

 Lots of bugs fixed. -fPIC code gen fixes, should be a big step 
 towards shared library support under Linux.

 http://www.digitalmars.com/d/changelog.html
And as a result of the template bug fixes, this is now possible: -------------------------------------- // Create a constant array of int or uint sized items // as a dchar[] string. n is the index of the last item. template makeLookup(alias entry, int n) { static if (n == -1) // start with an empty array... const dchar [] makeLookup = ""; else // ... and fill it up const dchar [] makeLookup = makeLookup!(entry, n-1) ~ cast(dchar)entry!(n); } // only needed to workaround a DMD 0.145 bug template LookupTable(alias entry, int n) { const LookupTable = cast(typeof(entry!(0)) [])makeLookup!(entry, n); } // USAGE: Let's make a factorial lookup table template factorial(uint n) { static if (n<2) const uint factorial = 1; else const factorial = n * factorial!(n-1); } // Make an array of all the factorials from 0 to 13 (14!> uint.max) const smallfactorials = LookupTable!(factorial, 13); import std.stdio; void main() { for (int i=0; i<smallfactorials.length; ++i) writefln(i, " ", smallfactorials[i]); }
Fascinating... I had to look at that for awhile to figure out what you were up to! -JJR
Yes, while that is fascinating it's still largely unreadable until you grok the exploitation of dchars and strings! Wow... -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O M-- V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e h>--->++ r+++ y+++ ------END GEEK CODE BLOCK------ James Dunne
Jan 31 2006
prev sibling next sibling parent Dave <Dave_member pathlink.com> writes:
In article <drk0de$1f4j$1 digitaldaemon.com>, Walter Bright says...
Lots of bugs fixed. -fPIC code gen fixes, should be a big step towards 
shared library support under Linux.

http://www.digitalmars.com/d/changelog.html
All I can say is Wow! - Dave
Jan 31 2006
prev sibling parent reply Hasan Aljudy <hasan.aljudy gmail.com> writes:
Walter Bright wrote:
 Lots of bugs fixed. -fPIC code gen fixes, should be a big step towards 
 shared library support under Linux.
 
 http://www.digitalmars.com/d/changelog.html
 
 
Sorry for my ignorace .. but: What's -fPIC? What does it do?
Jan 31 2006
parent reply John Reimer <terminal.node gmail.com> writes:
Hasan Aljudy wrote:
 Walter Bright wrote:
 Lots of bugs fixed. -fPIC code gen fixes, should be a big step towards 
 shared library support under Linux.

 http://www.digitalmars.com/d/changelog.html
Sorry for my ignorace .. but: What's -fPIC? What does it do?
It's a flag critical to gcc for building shared libraries on Linux (lib*.so). It stands for "Position Independent Code." With this flag, in theory, DMD finally supports Linux shared libraries. -JJR
Jan 31 2006
parent Carlos Santander <csantander619 gmail.com> writes:
John Reimer escribió:
 Hasan Aljudy wrote:
 Sorry for my ignorace .. but:
 What's -fPIC? What does it do?
It's a flag critical to gcc for building shared libraries on Linux (lib*.so). It stands for "Position Independent Code." With this flag, in theory, DMD finally supports Linux shared libraries. -JJR
Does it work? Can DMD really create .so files? -- Carlos Santander Bernal
Feb 01 2006