Installation on (64 bit) Linux

2009-04-28 Thread Brandon Moore
I managed to get a working system-wide dmd installation.

It would have been easier if the Ubuntu packages or linux installation
instructions actually set things up so the compiler could find the
interface definitions, and if the required dependencies on a 64-bit
(Ubuntu) system were documented outside the forums (maybe even
automatically in the debs).

It would also help if installation instructions were linked more 
prominently, like from the download page, and high on the side-bar.
In firefox, at 1280x1024, on a fresh Ubuntu 9.04 installation
the Tools:DMD D Compiler link that ultimately leads to installation
instructions is off the bottom of the screen on.
http://www.digitalmars.com/d/
I'd suggest a nice Getting D link up in the first panel with Overview 
and the rest.

Brief details:

dmd.conf, in all distributions, has include paths like
-...@p%/../../src/phobos
This will not work if dmd.conf is under $(prefix)/bin and
the interfaces under $(prefix)/src.

The 2.028 deb omits druntime entirely!

The linux install instructions do not mention that you should be
able to just run the binaries out of an unpacked zip.
(presumably the ../../src that causes so much pain everywhere else
is meant to get from dmd/linux/bin to dmd/src).

On the other hand, the linux install instructions don't mention that
you should also copy /dmd/src into system directories as well if you
are going for a system-wide install, and that dmd.conf needs editing
if you copy it to /etc (stating /etc/../../src/phobos/object.d is fun).

The gcc-multilibs stuff you need to compile on a 64 bit system
is not documented anywhere (in particular, not included as a dependency
of 64-bit debs).

In full detail:

The ubuntu packages are both broken. The 1.048 package has a bogus 
dmd.conf that sends the compiler looking for object.d at /usr/src/phobos/
object.d when it was installed to /usr/local/src/phobos/phobos/object.d. 
Fixing dmd.conf seems to be enough to get it working, after fixing the 64-
bit stuff described later.

The 2.028 package is completely broken, completely omitting the druntime 
directory and consequently object.d, as well as having a similarly bogus
dnd.conf.

The online linux installation instructions at
http://www.digitalmars.com/d/2.0/dmd-linux.html#installation
neglect to mention the compiler will work if run in-place from
an unpacked zip. The closest they come is if you happen to extend your
path to run them out of the unpacked zip, in which case all the cruft
the other steps direct you to copy into your system directories will
be ignored.

Assuming you want a system-wide installation, the instructions
say nothing about copying the interfaces from dmd/src (and the
readmes (as well as the directory name) suggest it just contains
source, not critically important interface files the compiler
needs to be able to find at runtime), or the need to edit
dmd.conf.

Once the above is sorted out those of us on 64-bit platforms still
need to get the right 32 bit libraries. A fairly mysterious linker
error about libpthread eventually suggests a 32-bit glibc is required,
which I had. A bit of searching turned up Walter's instructions:

http://www.digitalmars.com/pnews/read.php?
server=news.digitalmars.comgroup=digitalmars.D.announceartnum=15219

To compile 32 bit programs under ub64:
  sudo apt-get install gcc-multilib libc6-i386 lib6-dev-i386

To run 32 bit programs:
  sudo apt-get install gcc-multilib
  sudo apt-get install g++-multilib


Re: pyd still usable?

2009-04-28 Thread Jarrett Billingsley
On Tue, Apr 28, 2009 at 4:05 AM, Simen Haugen si...@norstat.no wrote:

 It uses templates for bindings, and if I remember correctly, dmd hits the
 limit for max variable name length when using templates.
 I hit the limit somewhere around 8 functions I think.

Actually the name limit hasn't been a problem for several months now.
DMD Win now MD5-hashes long symbol names so it's now impossible (?) to
crash OPTLINK by having long symbol names.  However, this has simply
fixed one problem to reveal another: OPTLINK will die if there are too
many fixups in a single object.  Just a hard crash.  This happens a
lot in Pyd-like code with several classes and methods wrapped.

 Might work on linux, but I haven't tried.

It does.  The only weak link is OPTLINK, which is only used by DMD Win.


Re: Get the name of a function and the parameters?

2009-04-28 Thread Jacob Carlborg

Jarrett Billingsley wrote:

On Mon, Apr 27, 2009 at 6:56 AM, Jacob Carlborg d...@me.com wrote:


I found that this:

void foo (int x, int y)
{
}

void main ()
{
   pragma(msg, typeof(foo).stringof);
}

gave this result:

void function(int x, int y)

So now I just have to get the names out of there.


Interesting!  I wonder if that changed recently.


I don't think so, I'm using gdc.


Re: D-styled data file

2009-04-28 Thread Saaa
I changed the prototype to:

void get(in char[] varName, ...)

I'm not totally happy with it because I only need one variadic argument and 
:

How do I get the .stringof of an variadic type?
_arguments[0].stringof doesn't work :)

How do I mutate the original argument? (ref)

Please tell me if I'm on the totally wrong track here.

---
module ddata.main;

import std.file;
import std.stdio;
import std.string;


void main()
{
 char[] filename = `data.dat`;
 char[][] file;

 try{
  file = splitlines( cast(char[])read(filename) );
 }
 catch{
  throw new Exception(Couldn't load :  ~ filename);
 }

 DData file_dd = new DData(file);
 int i;
 file_dd.get(`i`, i);
}


class DData
{

 private char[][] _file;

 this(char[][] file)
 {
  _file = file.dup;
 }

 void get(in char[] varName, ...)
 {
  char[] type = _arguments[0].stringof;
  writefln (type);
  foreach(int i, char[] line; _file)
  {
   if(line[0..type.length] == type)
   {
   writefln (i);
   break;
   }
   writefln (`failed`);
  }
 }
}
--- 




Re: Get the name of a function and the parameters?

2009-04-28 Thread Jarrett Billingsley
On Tue, Apr 28, 2009 at 3:07 PM, grauzone n...@example.net wrote:

 I'd like to pass several functions at once. Is there a way to make this
 variadic? The obvious approach (writing NameOfFunc(alias f...)) fails with
 a syntax error.

Sure, you'd just make it NameOfFunc(f...) and then recursively
instantiate, converting one item at a time to its name until f.length
== 0.

Alternatively, you can write a compile-time map and use NameOfFunc as
the mapping predicate.


Re: Get the name of a function and the parameters?

2009-04-28 Thread Daniel Keep


Jarrett Billingsley wrote:
 On Tue, Apr 28, 2009 at 3:07 PM, grauzone n...@example.net wrote:
 I'd like to pass several functions at once. Is there a way to make this
 variadic? The obvious approach (writing NameOfFunc(alias f...)) fails with
 a syntax error.
 
 Sure, you'd just make it NameOfFunc(f...) and then recursively
 instantiate, converting one item at a time to its name until f.length
 == 0.
 
 Alternatively, you can write a compile-time map and use NameOfFunc as
 the mapping predicate.

That requires f to be a type, which loses you the actual names.  And you
cannot (last time I checked) have aliases in a tuple.

  -- Daniel