Nick is clearly an idiot (Was: "make -fposix.mak")

2011-07-29 Thread Nick Sabalausky
"Nick Sabalausky"  wrote in message 
news:j106ib$1t43$1...@digitalmars.com...
> Am I forgetting something, or is "make -fposix.mak" supposed to build the 
> DMD executable on linux. I'm just getting:
>
> make: Nothing to be done for `all'.
>
> This is on the zipped 2.054 release, from the "src/dmd" directory.
>
> It seemed to work for 1.066
>

I gotta learn to 1. STFU and 2. Quit the late-night coding:

I realized about 15 seconds later I had already built the executable, which 
was still up-to-date...




Re: "make -fposix.mak"

2011-07-29 Thread Jonathan M Davis
On Saturday 30 July 2011 01:59:20 Nick Sabalausky wrote:
> Am I forgetting something, or is "make -fposix.mak" supposed to build the
> DMD executable on linux. I'm just getting:
> 
> make: Nothing to be done for `all'.
> 
> This is on the zipped 2.054 release, from the "src/dmd" directory.
> 
> It seemed to work for 1.066

It looks like it decided that there's no need to build, because there have 
been no changes since the last build. Try cleaning first:

make -f posix.mak clean
make -f posix.mak

- Jonathan M Davis


Re: "make -fposix.mak"

2011-07-29 Thread Nick Sabalausky
"Nick Sabalausky"  wrote in message 
news:j106ib$1t43$1...@digitalmars.com...
> Am I forgetting something, or is "make -fposix.mak" supposed to build the 
> DMD executable on linux. I'm just getting:
>
> make: Nothing to be done for `all'.
>
> This is on the zipped 2.054 release, from the "src/dmd" directory.
>
> It seemed to work for 1.066
>

Of course, on 1.066 I used linux.mak, but my understanding is that on newer 
DMDs posix.mak is supposed to be used instead.




"make -fposix.mak"

2011-07-29 Thread Nick Sabalausky
Am I forgetting something, or is "make -fposix.mak" supposed to build the 
DMD executable on linux. I'm just getting:

make: Nothing to be done for `all'.

This is on the zipped 2.054 release, from the "src/dmd" directory.

It seemed to work for 1.066




Problem with take(map())

2011-07-29 Thread bearophile
D2 code:


import std.stdio, std.algorithm, std.range;
auto foo(int p) {
return map!((int n){ return p; })(iota(3));
}
void main() {
writeln(take(foo(2), 20));
}


To me it prints:
[4221068, 4221068, 4221068]

Do you know if this is a known bug/problem?

Bye,
bearophile


Re: ref int value() { return m_value; } - uses?

2011-07-29 Thread Jonathan M Davis
On Saturday 30 July 2011 10:57:39 Joel Christensen wrote:
> What use is the property thing?
> 
> class Test {
>   private int m_value;
>   @property ref int value() { return m_value; }
> }
> 
> void main() {
>   auto test = new Test;
>   test.value += 1;
> }
> 
> Or this:
> import std.stdio: writeln;
> import std.conv: to;
> 
> class Test {
>   private string m_text;
> 
>   ref auto text( string tx ) {
>   if ( tx.length > 4 )
>   m_text = m_text[ 0 .. 4 ];
>   return m_text;
>   }
> 
>   override string toString() {
>   return text( m_text );
>   }
> }
> 
> void main() {
>   auto test = new Test;
>   with( test ) {
>   text( to!string( test ) ) = "feet";
>   writeln( test );
>   text( to!string( test ) ) ~= "@";
>   writeln( test );
>   }
> }

http://www.d-programming-language.org/property.html

@property makes it so that the function is used syntactically as a variable 
rather than a function. And while it's not currently enforced, eventually, you 
will _have_ to use property functions with the variable syntax. For instance, 
empty on ranges is marked with @property:

assert(range.empty);

You could currently do

assert(empty(range));

but eventually that will be illegal. Property functions allow you to have 
public member variables become functions (or functions become public member 
variables) without having to change the code which uses them. They're 
generally used instead of getters and setters.

In this particular case, the property function returns a ref, so it's both a 
getter and a setter.

- Jonathan M Davis 


ref int value() { return m_value; } - uses?

2011-07-29 Thread Joel Christensen

What use is the property thing?

class Test {
private int m_value;
@property ref int value() { return m_value; }
}

void main() {
auto test = new Test;
test.value += 1;
}

Or this:
import std.stdio: writeln;
import std.conv: to;

class Test {
private string m_text;

ref auto text( string tx ) {
if ( tx.length > 4 )
m_text = m_text[ 0 .. 4 ];
return m_text;
}

override string toString() {
return text( m_text );
}
}

void main() {
auto test = new Test;
with( test ) {
text( to!string( test ) ) = "feet";
writeln( test );
text( to!string( test ) ) ~= "@";
writeln( test );
}
}


Re: DMD's kernel32.lib missing symbols?

2011-07-29 Thread Simon

On 29/07/2011 19:27, simendsjo wrote:

On 29.07.2011 19:13, Simon wrote:

On 29/07/2011 11:14, simendsjo wrote:

Not sure how I can search for symbols in the library, but it seems the
library is missing functions.
I've tried using coffimplib on kernel32.lib from the Windows SDK, but it
neither produces a new library or give me an error.

What Windows version is the library based on?
How can I check what symbols exists?
Is there a way to convert WinSDK's library to omf?


Shows how to make your own import lib for windows system dll:

http://www.sstk.co.uk/d.php

Been ages since I did that though so let me know if you have problems.



I've tried using implib too, but replacing dmd's own kernel32.lib seems
to create problems.


What sort of problems? It's worked perfectly for me so far.

--
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk


Re: Frontend and backend communication

2011-07-29 Thread Dainius (GreatEmerald)
Yes, this is a library, so a main() there would be rather pointless.
However, it seems that on many occasions compilers will simply not
acknowledge anything without one, so I guess at least a declaration is
in order... I'll have to try that out once I get back on Windows.

Meanwhile, on Linux, I am getting these linker errors instead:


/usr/lib64/gcc/x86_64-suse-linux/4.5/../../../../lib64/libphobos2.a(datetime_3a6_1ec.o):
In function `_D3std8datetime5Clock11currStdTimeFNdNeZl':
std/datetime.d:(.text._D3std8datetime5Clock11currStdTimeFNdNeZl+0x1d):
undefined reference to `clock_gettime'

/usr/lib64/gcc/x86_64-suse-linux/4.5/../../../../lib64/libphobos2.a(time_c6_4d1.o):
In function `_D4core4time12TickDuration12_staticCtor7OFNeZv':
src/core/time.d:(.text._D4core4time12TickDuration12_staticCtor7OFNeZv+0x1f):
undefined reference to `clock_getres'

/usr/lib64/gcc/x86_64-suse-linux/4.5/../../../../lib64/libphobos2.a(time_c6_4d1.o):
In function 
`_D4core4time12TickDuration14currSystemTickFNdNeZS4core4time12TickDuration':

src/core/time.d:(.text._D4core4time12TickDuration14currSystemTickFNdNeZS4core4time12TickDuration+0x1f):
undefined reference to `clock_gettime'

Is it related, or is it a different issue altogether?

Also, apparently SDL and Lua don't like being statically linked. Good
thing the backend doesn't use SDL any more, then! And Lua does link,
although reluctantly and with linker warnings. Reportedly they are
nothing to worry about too much, but still...


Re: Frontend and backend communication

2011-07-29 Thread Jesse Phillips
Dainius (GreatEmerald) Wrote:

> So, now my (static) library nearly links in Win32. There is only one
> link error, and apparently it's generated by phobos:
> 
> ..\lib\phobos.lib(dmain2)
>  Error 42: Symbol Undefined __end
> 
> Any clues about what is happening? Admittedly, that phobos.lib is from
> March 20, 2011, so it's rather old by now.

I didn't follow this discussion, but it is telling you there is no main 
function. Are you compiling a library? Maybe you should try giving your program 
a main?


Re: DMD's kernel32.lib missing symbols?

2011-07-29 Thread simendsjo

On 29.07.2011 19:13, Simon wrote:

On 29/07/2011 11:14, simendsjo wrote:

Not sure how I can search for symbols in the library, but it seems the
library is missing functions.
I've tried using coffimplib on kernel32.lib from the Windows SDK, but it
neither produces a new library or give me an error.

What Windows version is the library based on?
How can I check what symbols exists?
Is there a way to convert WinSDK's library to omf?


Shows how to make your own import lib for windows system dll:

http://www.sstk.co.uk/d.php

Been ages since I did that though so let me know if you have problems.



I've tried using implib too, but replacing dmd's own kernel32.lib seems 
to create problems.


Re: DMD's kernel32.lib missing symbols?

2011-07-29 Thread Simon

On 29/07/2011 11:14, simendsjo wrote:

Not sure how I can search for symbols in the library, but it seems the
library is missing functions.
I've tried using coffimplib on kernel32.lib from the Windows SDK, but it
neither produces a new library or give me an error.

What Windows version is the library based on?
How can I check what symbols exists?
Is there a way to convert WinSDK's library to omf?


Shows how to make your own import lib for windows system dll:

http://www.sstk.co.uk/d.php

Been ages since I did that though so let me know if you have problems.

--
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk


Re: Versioned extern?

2011-07-29 Thread Trass3r

http://d.puremagic.com/issues/show_bug.cgi?id=5739#c3


Re: Empy program running time

2011-07-29 Thread Steven Schveighoffer
On Fri, 29 Jul 2011 10:50:52 -0400, bearophile   
wrote:



Steven Schveighoffer:

For example, D needs to call all the module ctors and do the import  
cycle

detection algorithm.


Even for an empty program?


Yes.  I bet even an empty program has on the order of 50 module ctor/dtors  
to run.  All the runtime can contain module ctor/dtors, and those modules  
are compiled in no matter what.  Plus dmd adds hidden modules with  
ctor/dtors.


There are other initializations, such as the GC, setting up the main  
thread, etc.



0.11 seconds is not unreasonable.


It means about 170_000_000 CPU clock ticks, to me it seems a lot.


I guess if you want to have an empty program benchmark?  It doesn't seem  
to mean much to me...


If it was on the order of seconds, I'd agree with you.  .11 seconds is  
barely noticeable.


But I'll also stress that timings at this precision can be fairly  
volatile.


I think this timing precision is not so bad.


What I mean is, the timing for a program can easily vary by 10ths of a  
second between runs, depending on what's happening on the computer.  Make  
sure you do an average, and not a single run to do these kinds of tests.


-Steve


Re: Empy program running time

2011-07-29 Thread bearophile
Steven Schveighoffer:

> For example, D needs to call all the module ctors and do the import cycle  
> detection algorithm.

Even for an empty program?


> 0.11 seconds is not unreasonable.

It means about 170_000_000 CPU clock ticks, to me it seems a lot.


> But I'll also stress that timings at this precision can be fairly volatile.

I think this timing precision is not so bad.

Bye,
bearophile


Re: Versioned extern?

2011-07-29 Thread Steven Schveighoffer

On Sat, 23 Jul 2011 23:35:39 -0400, Nick Sabalausky  wrote:


Is there a way to have a section of code be extern(C) on one OS and
extern(Windows) on another OS, without resorting making the code in  
question

a mixin?

These doesn't appear to work:

--
version(Windows)
{
enum callingConvention = "Windows";
}
else
{
enum callingConvention = "C";
}

extern(mixin(callingConvention ))
{
/+ ...code here... +/
}
--
version(Windows)
{
extern(Windows):
}
else
{
extern(C):
}

/+ ...code here... +/

extern(D):
--



does this work?

private void fnImpl(...)
{
   // code here
}

version(Windows)
{
   extern(Windows) fn(...) {fnImpl();}
}
else
{
   extern(C) fn(...) {fnImpl();}
}

-Steve


Re: Versioned extern?

2011-07-29 Thread Aleksandar Ružičić
Ouh, haven't read that you don't want code to be mixed-in.. In that
case.. I dunno :)

2011/7/29 Aleksandar Ružičić :
> If I'm not mistaken extern() accepts only Identifier, not expression.
> I'm not really sure what's the best way to do that but I belive this
> should work (haven't tested):
>
> enum code = q{
>
>   void func() {
>           // do something
>   }
> };
>
> version (Windows) {
>   extern (Windows) {
>       mixin(code);
>   }
> } else {
>   extern (C) {
>       mixin(code);
>   }
> }
>
> On Sun, Jul 24, 2011 at 5:35 AM, Nick Sabalausky  wrote:
>> Is there a way to have a section of code be extern(C) on one OS and
>> extern(Windows) on another OS, without resorting making the code in question
>> a mixin?
>>
>> These doesn't appear to work:
>>
>> --
>> version(Windows)
>> {
>>    enum callingConvention = "Windows";
>> }
>> else
>> {
>>    enum callingConvention = "C";
>> }
>>
>> extern(mixin(callingConvention ))
>> {
>>    /+ ...code here... +/
>> }
>> --
>> version(Windows)
>> {
>>    extern(Windows):
>> }
>> else
>> {
>>    extern(C):
>> }
>>
>> /+ ...code here... +/
>>
>> extern(D):
>> --
>>
>>
>>
>>
>>
>


Re: Versioned extern?

2011-07-29 Thread Aleksandar Ružičić
If I'm not mistaken extern() accepts only Identifier, not expression.
I'm not really sure what's the best way to do that but I belive this
should work (haven't tested):

enum code = q{

   void func() {
   // do something
   }
};

version (Windows) {
   extern (Windows) {
   mixin(code);
   }
} else {
   extern (C) {
   mixin(code);
   }
}

On Sun, Jul 24, 2011 at 5:35 AM, Nick Sabalausky  wrote:
> Is there a way to have a section of code be extern(C) on one OS and
> extern(Windows) on another OS, without resorting making the code in question
> a mixin?
>
> These doesn't appear to work:
>
> --
> version(Windows)
> {
>    enum callingConvention = "Windows";
> }
> else
> {
>    enum callingConvention = "C";
> }
>
> extern(mixin(callingConvention ))
> {
>    /+ ...code here... +/
> }
> --
> version(Windows)
> {
>    extern(Windows):
> }
> else
> {
>    extern(C):
> }
>
> /+ ...code here... +/
>
> extern(D):
> --
>
>
>
>
>


Re: Empy program running time

2011-07-29 Thread Steven Schveighoffer
On Fri, 29 Jul 2011 09:37:36 -0400, bearophile   
wrote:


On an oldish Windows PC an empty C program generated by GCC takes about  
0.03 seconds to run. An empty D2 program runs in about 0.11 seconds. Is  
this expected/good/acceptable/fixable?


It is expected.  A d program must initialize both the C runtime and the D  
runtime, whereas a C program only needs to initialize C.


For example, D needs to call all the module ctors and do the import cycle  
detection algorithm.


0.11 seconds is not unreasonable.  But I'll also stress that timings at  
this precision can be fairly volatile.


-Steve


Re: Empy program running time

2011-07-29 Thread Pelle
On Fri, 29 Jul 2011 15:37:36 +0200, bearophile   
wrote:


On an oldish Windows PC an empty C program generated by GCC takes about  
0.03 seconds to run. An empty D2 program runs in about 0.11 seconds. Is  
this expected/good/acceptable/fixable?


Bye,
bearophile


That's a lot better than I expected! I don't think anyone would notice  
such a small difference.


Empy program running time

2011-07-29 Thread bearophile
On an oldish Windows PC an empty C program generated by GCC takes about 0.03 
seconds to run. An empty D2 program runs in about 0.11 seconds. Is this 
expected/good/acceptable/fixable?

Bye,
bearophile


Re: Frontend and backend communication

2011-07-29 Thread Dainius (GreatEmerald)
So, now my (static) library nearly links in Win32. There is only one
link error, and apparently it's generated by phobos:

..\lib\phobos.lib(dmain2)
 Error 42: Symbol Undefined __end

Any clues about what is happening? Admittedly, that phobos.lib is from
March 20, 2011, so it's rather old by now.


Ubuntu installation not working

2011-07-29 Thread Confused user
On an Ubuntu 11.04 system, I've been using the D1 version.  Yesterday, I tried
to remove it, and install the D2 version.  When trying to compile "hello
world", I always get

object.d: Error: module object is in file 'object.d' which cannot be read
Specify path to file 'object.d' with -I switch

when I remove D2 and reinstall D1 (always using the one click installer), I
always get this error for both versions.  How do I get back to having a
working installation?


DMD's kernel32.lib missing symbols?

2011-07-29 Thread simendsjo
Not sure how I can search for symbols in the library, but it seems the 
library is missing functions.
I've tried using coffimplib on kernel32.lib from the Windows SDK, but it 
neither produces a new library or give me an error.


What Windows version is the library based on?
How can I check what symbols exists?
Is there a way to convert WinSDK's library to omf?


Re: Frontend and backend communication

2011-07-29 Thread Dainius (GreatEmerald)
I see. Well, I guess I'll have to stick to static ones until this gets
sorted out.