Re: dmd.conf... again

2015-08-12 Thread Atila Neves via Digitalmars-d-learn
On Wednesday, 12 August 2015 at 12:21:14 UTC, Rikki Cattermole 
wrote:

On 13/08/2015 12:16 a.m., Atila Neves wrote:

[...]


Perhaps this small snippet from my Windows install might shred 
some light. Specifically the LIB property.


[Environment32]
LIB=%@P%\..\lib
LINKCMD=%@P%\link.exe


[Environment64]
LIB=%@P%\..\lib64


Tried setting LIB, still doesn't work. Sigh.

Atila


Re: dmd.conf... again

2015-08-12 Thread wobbles via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 14:05:57 UTC, Atila Neves wrote:

On Wednesday, 12 August 2015 at 13:46:24 UTC, wobbles wrote:
On Wednesday, 12 August 2015 at 13:00:45 UTC, Atila Neves 
wrote:
On Wednesday, 12 August 2015 at 12:40:49 UTC, Adam D. Ruppe 
wrote:

[...]


I downloaded the zip, added linux/bin64 to PATH, tried 
compiling a hello world and got:


usr/bin/ld: cannot find -l:libphobos2.a

That's when I started trying to set the configuration but 
nothing seems to work.


Atila


Have you run dmd from the directory you unzipped it to?
libphobos2.a is in there I think, so ld wouldn't be able to 
find it.


Just did, didn't work. Tried it from lib64 and lib32 as well, 
nothing.


Atila


Hmm, I'll setup a VM later this evening to test, see if I can 
figure it out. This really should be easier.




Re: Does D have syntax for adding subscopes to classes?

2015-08-12 Thread sigod via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 15:21:28 UTC, GregoryP wrote:
I'm just wondering if, or how much of the following is possible 
in some way in D:


class Foo {
int x;
sub Bar {
int x;
int getFooX(){ return super.x; }
sub FooBar {
int x;
int y;
int addXes(){ return x + super.x + super.super.x; }
}
}
}

Where the Xes are accessible outside the class by Foo.x, 
Foo.Bar.x, Foo.Bar.FooBar.x.


[Nested classes][0] maybe?

[0]: http://dlang.org/class.html#nested


Re: dmd.conf... again

2015-08-12 Thread Atila Neves via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 15:22:39 UTC, wobbles wrote:

On Wednesday, 12 August 2015 at 14:05:57 UTC, Atila Neves wrote:

On Wednesday, 12 August 2015 at 13:46:24 UTC, wobbles wrote:
On Wednesday, 12 August 2015 at 13:00:45 UTC, Atila Neves 
wrote:
On Wednesday, 12 August 2015 at 12:40:49 UTC, Adam D. Ruppe 
wrote:

[...]


I downloaded the zip, added linux/bin64 to PATH, tried 
compiling a hello world and got:


usr/bin/ld: cannot find -l:libphobos2.a

That's when I started trying to set the configuration but 
nothing seems to work.


Atila


Have you run dmd from the directory you unzipped it to?
libphobos2.a is in there I think, so ld wouldn't be able to 
find it.


Just did, didn't work. Tried it from lib64 and lib32 as well, 
nothing.


Atila


Hmm, I'll setup a VM later this evening to test, see if I can 
figure it out. This really should be easier.


It really should. I straced it and it's trying to link to phobos 
with `-l:libphobos2.a`. I've never seen a colon in library 
options before and the (ancient) gcc on the system doesn't seem 
to like it one bit. I added a hand-compiled gcc 4.9 to my PATH 
and... it worked.


Atila


Re: dmd.conf... again

2015-08-12 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 15:30:09 UTC, Atila Neves wrote:
I've never seen a colon in library options before and the 
(ancient) gcc on the system doesn't seem to like it one bit.


ohhh, I have seen that before, I was on a CentOS 5 VM and it 
didn't like that colon either. It was added to dmd about two or 
three years ago, I remember it breaking my thing.


I think I 'fixed' it by just linking manually in the makefile for 
that vm.




Re: Does D have syntax for adding subscopes to classes?

2015-08-12 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 15:24:43 UTC, sigod wrote:

[Nested classes][0] maybe?



Example with them:

class Foo {
int x;
class Bar_ { // underscore cuz we have to declare 
variable too

int x;
int getFooX() { return this.outer.x; }
class FooBar_ {
int x;
int y;
int addXes() { return x + this.outer.x + 
this.outer.outer.x; }

}
FooBar_ FooBar;
this() {
FooBar = new FooBar_; // the var must 
also be initialized in a ctor

}
}
Bar_ Bar;
this() {
Bar = new Bar_; // same out here
}
}
void main() {
auto foo = new Foo();
import std.stdio;
writeln(foo.Bar.FooBar.addXes());
}


Re: dmd.conf... again

2015-08-12 Thread via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 15:30:09 UTC, Atila Neves wrote:

On Wednesday, 12 August 2015 at 15:22:39 UTC, wobbles wrote:
On Wednesday, 12 August 2015 at 14:05:57 UTC, Atila Neves 
wrote:

On Wednesday, 12 August 2015 at 13:46:24 UTC, wobbles wrote:
On Wednesday, 12 August 2015 at 13:00:45 UTC, Atila Neves 
wrote:
On Wednesday, 12 August 2015 at 12:40:49 UTC, Adam D. Ruppe 
wrote:

[...]


I downloaded the zip, added linux/bin64 to PATH, tried 
compiling a hello world and got:


usr/bin/ld: cannot find -l:libphobos2.a

That's when I started trying to set the configuration but 
nothing seems to work.


Atila


Have you run dmd from the directory you unzipped it to?
libphobos2.a is in there I think, so ld wouldn't be able to 
find it.


Just did, didn't work. Tried it from lib64 and lib32 as well, 
nothing.


Atila


Hmm, I'll setup a VM later this evening to test, see if I can 
figure it out. This really should be easier.


It really should. I straced it and it's trying to link to 
phobos with `-l:libphobos2.a`. I've never seen a colon in 
library options before and the (ancient) gcc on the system 
doesn't seem to like it one bit. I added a hand-compiled gcc 
4.9 to my PATH and... it worked.


Atila


From man ld :)
-l namespec
Add the archive or object file specified by namespec to the list 
of files to link. This option may be used any number of times.  
If namespec is of the form :filename, ld will search the library 
path for a file called filename, otherwise it will search the 
library path for a file called libnamespec.a.


On systems which support shared libraries, ld may also search for 
files other than libnamespec.a.  Specifically, on ELF and SunOS 
systems, ld will search a directory for a library called 
libnamespec.so before searching for one called libnamespec.a.  
(By convention, a .so extension indicates a shared library.)  
Note that this behavior does not apply to :filename, which always 
specifies a file called filename.



So in this case it could probably work with -lphobos2.
Maybe -L-l:libphobos2.a was chosen to force the linking with the 
static lib (as can be seen in the second paragraph for systems 
that supports both).


// Joakim


Re: dmd.conf... again

2015-08-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 12 August 2015 at 15:49:37 UTC, Joakim Brännström 
wrote:

From man ld :)


It's only there if you have a new enough ld for the feature to be 
supported!


One of the work CentOS VMs I have to use sometimes doesn't have 
it.


$ ld --version
GNU ld version 2.17.50.0.6-14.el5 20061020
Copyright 2005 Free Software Foundation, Inc.
lol

$ man ld

   -larchive
   --library=archive
   Add archive file archive to the list of files to link. 
 This option
   may  be used any number of times.  ld will search its 
path-list for
   occurrences of libarchive.a for every archive 
specified.
   On systems which support shared libraries, ld may also 
 search  for
   libraries  with  extensions  other than .a.  
Specifically, on ELF
   and SunOS systems, ld will search a directory for a 
library with an
   extension  of  .so  before searching for one with an 
extension of
   .a.  By convention, a .so extension indicates a 
shared library.







Re: Hello Assembly!

2015-08-12 Thread Taylor Hillegeist via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 22:32:30 UTC, Adam D. Ruppe wrote:
On Wednesday, 12 August 2015 at 22:18:41 UTC, Adam D. Ruppe 
wrote:

[...]


Here's an example:

[...]


Wow, very cool thanks!


Hello Assembly!

2015-08-12 Thread Taylor Hillegeist via Digitalmars-d-learn
So i was playing around with the D inline assembly trying to make 
it say hello world on my windows setup...


void main(){
asm
{
myhello:
db HELLO, WORLD$;
mov EAX , myhello;
mov AH, 0x09;
int 0x21;
}
}


I figure this should do it. but i'm running into problems. 
Anybody know why?


Re: Hello Assembly!

2015-08-12 Thread Justin Whear via Digitalmars-d-learn
On Wed, 12 Aug 2015 22:10:30 +, Taylor Hillegeist wrote:

 I figure this should do it. but i'm running into problems. Anybody know
 why?

Describe problems


Re: More threads - Slower program ??

2015-08-12 Thread Yuxuan Shui via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 23:15:48 UTC, Adam D. Ruppe wrote:

On Wednesday, 12 August 2015 at 23:06:32 UTC, Yuxuan Shui wrote:

What is wrong here?


I didn't look too closely, but there's some memory allocations 
going on there which have the potential of locking all the 
threads any time one of them tries to allocate.


Parallelism's benefits are largely erased by the memory 
allocator lock and can be set back by the cache being 
invalidated as it jumps around that allocated memory, so you 
generally want to make sure the threads are doing work on local 
variables only.


This restricts what you can do with strings, since most the 
std.string functions allocate new strings for their return 
values...


Is there a way to do thread-local allocations?


More threads - Slower program ??

2015-08-12 Thread Yuxuan Shui via Digitalmars-d-learn
Here is a small program 
(https://gist.github.com/yshui/a426f73be77d1d699555) that uses 
taskPool to parallely reading from /proc/pid/ and sum the swap 
usage.


Individual tasks has zero dependency between each other, but when 
I remove the 'defaultPoolThreads(1)' line, the programs takes 8x 
more CPU time and also runs longer in total (I have 12 cores).


What is wrong here?



Re: Hello Assembly!

2015-08-12 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 22:18:41 UTC, Adam D. Ruppe wrote:
The way you'd typically do it on Windows is to just call one of 
the win32 api functions, similarly to how you'd do it from C or 
regular D, just calling the functions manually.


Here's an example:

import core.sys.windows.windows; // make the names of C funcs 
available


void main() {
int written; // just let D handle the local var for us

asm
{
// the goal is:
// WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), 
myhello.ptr, myhello.length, written, null);


// so call GetStdHandle first
push STD_OUTPUT_HANDLE;
call GetStdHandle;
// the return value is now in EAX
mov EBX, EAX; // save it for later in EBX

// we push arguments from right to left for the 
WriteConsoleA call..

push 0; // null
mov EAX, written; // local vars in D are available too
push EAX; // written
push 13; // length of HELLO, WORLD\n
lea EAX, myhello; // the address of our string
push EAX; // pointer
push EBX; // our saved handle from before
call WriteConsoleA;
jmp past_hello; // need to jump past the string since it 
isn't actually executable code!

myhello:
db HELLO, WORLD\n;
past_hello:
nop;
}
}




That should run successfully.

Putting the string in a db like that isn't ideal either, you 
should probably just put it in an ordinary D variable too so the 
compiler can place it in the right place.


Then you can also load it. Since D asm complains about the .ptr 
property thinking it means an instruction, I would do something 
like:


string hello = HELLO, WORLD\n;
auto myhello = hello.ptr;


Then you can just `mov EAX, myhello;` and it will work.


Re: Hello Assembly!

2015-08-12 Thread Taylor Hillegeist via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 22:18:41 UTC, Adam D. Ruppe wrote:
On Wednesday, 12 August 2015 at 22:10:32 UTC, Taylor Hillegeist 
wrote:
So i was playing around with the D inline assembly trying to 
make it say hello world on my windows setup...


Have you ever written assembly for Windows before? Your code 
looks more like DOS (aside from the EAX, which would be 
overwriten by the AH mov anyway! In DOS, I think it was DX.)


But DOS code won't work here anyway, since it was 16 bit and D 
makes 32 or 64 bit exes.


The way you'd typically do it on Windows is to just call one of 
the win32 api functions, similarly to how you'd do it from C or 
regular D, just calling the functions manually.


Ahh, It probably is! I was looking for a minimal example. DOS != 
Windows CMD


I was following the example on 
http://web.archive.org/web/20100529113659/http://home.comcast.net/~fbkotler/clueless.html


It is werid working with asm on windows... RISC/asm is much more 
fimilar to me..


Re: Hello Assembly!

2015-08-12 Thread Taylor Hillegeist via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 22:14:58 UTC, Justin Whear wrote:

On Wed, 12 Aug 2015 22:10:30 +, Taylor Hillegeist wrote:

I figure this should do it. but i'm running into problems. 
Anybody know why?


Describe problems


object.Error@(0): Access Violation

0x00402028
0x38004023
0x6C0018FF
0x38004023
0xE50018FF
0xA1004022
0x010041E0
0x3800
0x5C0018FF
0x3801
0xD00018FF
0xF40100FD
0x780018FD
0x1E0018FF


Thats pretty much it!


Re: More threads - Slower program ??

2015-08-12 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 23:06:32 UTC, Yuxuan Shui wrote:

What is wrong here?


I didn't look too closely, but there's some memory allocations 
going on there which have the potential of locking all the 
threads any time one of them tries to allocate.


Parallelism's benefits are largely erased by the memory allocator 
lock and can be set back by the cache being invalidated as it 
jumps around that allocated memory, so you generally want to make 
sure the threads are doing work on local variables only.


This restricts what you can do with strings, since most the 
std.string functions allocate new strings for their return 
values...


Should these aliases kind be illegal ?

2015-08-12 Thread anonymous via Digitalmars-d-learn
The following alias declaration is totally legal but actually 
it's not usable


---
class Foo
{
void something(size_t param){}
}

class Bar
{
private Foo foo;
this(){foo = new Foo;}
alias somethingelse = foo.something;
}

void main(string[] args)
{
auto bar = new Bar;
//bar.somethingelse(0u);
}
---

The call doesn't work but the declaration is fine. What is 
possible to make with this declaration ?


Re: Hello Assembly!

2015-08-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 12 August 2015 at 22:10:32 UTC, Taylor Hillegeist 
wrote:
So i was playing around with the D inline assembly trying to 
make it say hello world on my windows setup...


Have you ever written assembly for Windows before? Your code 
looks more like DOS (aside from the EAX, which would be 
overwriten by the AH mov anyway! In DOS, I think it was DX.)


But DOS code won't work here anyway, since it was 16 bit and D 
makes 32 or 64 bit exes.


The way you'd typically do it on Windows is to just call one of 
the win32 api functions, similarly to how you'd do it from C or 
regular D, just calling the functions manually.


Re: Should these aliases kind be illegal ?

2015-08-12 Thread Timon Gehr via Digitalmars-d-learn

On 08/13/2015 12:17 AM, anonymous wrote:

The following alias declaration is totally legal but actually it's not
usable

---
class Foo
{
 void something(size_t param){}
}

class Bar
{
 private Foo foo;
 this(){foo = new Foo;}
 alias somethingelse = foo.something;
}

void main(string[] args)
{
 auto bar = new Bar;
 //bar.somethingelse(0u);
}
---

The call doesn't work but the declaration is fine. What is possible to
make with this declaration ?


I believe it currently just does the same thing as:

---
class Foo{
void something(size_t param){}
}

class Bar{
private Foo foo;
this(){foo = new Foo;}
alias somethingelse = typeof(foo).something;
}
---

But IMO the appropriate response here is to just make it work as one 
would expect, not to make it illegal.


Attributes not propagating to objects via typeinfo?

2015-08-12 Thread rsw0x via Digitalmars-d-learn

Sample code:

class C{}
struct S{}

void main(){
import std.stdio;
auto c = new shared C();
auto s = new shared S();
writeln(typeid(c)); //modulename.C
writeln(typeid(s)); //shared(modulename.S)*
writeln(typeid(c).next); //null
writeln(typeid(s).next); //shared(modulename.S)
writeln(typeid(typeid(s).next) is typeid(TypeInfo_Shared)); 
//true

writeln(typeid(typeid(c)) is typeid(TypeInfo_Shared)); //false
}


What's the reason that the shared propagates to the typeinfo for 
the struct, but not for the class declaration?


Indivisual Incremental Compalation with dub

2015-08-12 Thread Freddy via Digitalmars-d-learn
I have a file that takes a while to compile with a static 
interface. Is there any way i can make dub keep the object file 
of only that file(for faster compilation)?


Re: Derelict, SDL, and OpenGL3: Triangle Tribulations

2015-08-12 Thread JN via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 05:58:23 UTC, BBasile wrote:

On Wednesday, 12 August 2015 at 05:46:27 UTC, Mike Parker wrote:

On Wednesday, 12 August 2015 at 05:34:22 UTC, BBasile wrote:

[...]



It seems to me that your driver is doing things it isn't 
actually supposed to do. This code is binding a vertex buffer 
object with a function which is supposed to bind a vertex 
array object. The only reason the vbo is bound at all is 
because of the call to glBindBuffer in the misnamed initVAO -- 
a function which never even initializes a vao. The spec 
actually requires a vao to be created and a shader program to 
be bound, so I would expect a conforming driver to show 
nothing.


I expect a couple of calls to glError will not come up empty.


Right, the triangle is well drawn but glGetError returns 1282. 
Maybe the OP has a different OGL implementation. At least 
NVidia driver renders a triangle for this code.


Depends on what context gets created in this case. A core profile 
context shouldn't render anything without a bound shader. NVidia 
likes backwards compatibility, so it's possible this code works, 
it's just using fixed function pipeline rendering, which isn't 
typically what people want when they mention GL3. Might as well 
use glBegin/glEnd, and it would work too.


Re: Derelict, SDL, and OpenGL3: Triangle Tribulations

2015-08-12 Thread BBasile via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 05:46:27 UTC, Mike Parker wrote:

On Wednesday, 12 August 2015 at 05:34:22 UTC, BBasile wrote:

[...]



It seems to me that your driver is doing things it isn't 
actually supposed to do. This code is binding a vertex buffer 
object with a function which is supposed to bind a vertex array 
object. The only reason the vbo is bound at all is because of 
the call to glBindBuffer in the misnamed initVAO -- a function 
which never even initializes a vao. The spec actually requires 
a vao to be created and a shader program to be bound, so I 
would expect a conforming driver to show nothing.


I expect a couple of calls to glError will not come up empty.


Right, the triangle is well drawn but glGetError returns 1282. 
Maybe the OP has a different OGL implementation. At least NVidia 
driver renders a triangle for this code.


Re: Derelict, SDL, and OpenGL3: Triangle Tribulations

2015-08-12 Thread DarthCthulhu via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 05:26:33 UTC, JN wrote:
You need a vertex and a fragment shader. You can't render 
anything in OGL3 without shaders.




I thought that was the case, but the tutorial I was looking at 
didn't have any shaders at that point. I added a shader program.


Also, you seem to be confusing Vertex Array Objects and Vertex 
Buffer Objects. You are creating a VBO and try to bind it as a 
VAO. You should put a glGenVertexArrays somewhere there.


Aha! Yes, that's it, thanks! Once I understood the difference 
between VAO and VBOs, it was easy to fix. Thanks!


On Wednesday, 12 August 2015 at 05:35:30 UTC, Mike Parker wrote:
On Wednesday, 12 August 2015 at 03:32:47 UTC, DarthCthulhu 
wrote:


So, any ideas what I'm doing wrong?


Too much to list. I suggest you get going with a good tutorial. 
One of the best I've seen is by Anton Gerdelan [1]. The four 
basic tutorials he has on his site will be enough to get you up 
and running. He used to have a lot more there, but he's 
published them all in a book. Even though there are numerous 
free resources online, I think Anton's ebook is well worth the 
~$9.00 you pay for it. His tutorials are quite detailed and do 
a lot more than showing you a bunch of code to copy and paste. 
Work your way through that book and you'll know your way around 
well enough to do what you need to do for any basic OpenGL 
renderer.


On Wednesday, 12 August 2015 at 05:54:13 UTC, Mike Parker wrote:

On Wednesday, 12 August 2015 at 05:35:30 UTC, Mike Parker wrote:


One of the best I've seen is by Anton Gerdelan [1]. The four


[1] http://antongerdelan.net/opengl/index.html


Thanks very much for the resource! I had already looked at about 
a dozen different OGL3.x tutorials online, but this was the one 
which clicked for me. I'll definitely look into getting his book.


Thanks again!



Re: dmd.conf... again

2015-08-12 Thread Atila Neves via Digitalmars-d-learn
On Wednesday, 12 August 2015 at 15:49:37 UTC, Joakim Brännström 
wrote:

On Wednesday, 12 August 2015 at 15:30:09 UTC, Atila Neves wrote:

[...]


From man ld :)
-l namespec
Add the archive or object file specified by namespec to the 
list of files to link. This option may be used any number of 
times.  If namespec is of the form :filename, ld will search 
the library path for a file called filename, otherwise it will 
search the library path for a file called libnamespec.a.


On systems which support shared libraries, ld may also search 
for files other than libnamespec.a.  Specifically, on ELF and 
SunOS systems, ld will search a directory for a library called 
libnamespec.so before searching for one called libnamespec.a.  
(By convention, a .so extension indicates a shared library.)  
Note that this behavior does not apply to :filename, which 
always specifies a file called filename.



So in this case it could probably work with -lphobos2.
Maybe -L-l:libphobos2.a was chosen to force the linking with 
the static lib (as can be seen in the second paragraph for 
systems that supports both).


Yeah, pretty sure that was it: when I called gcc myself it linked 
to the shared version. Maybe I should file a bug report for at 
least a proper error message when using it on ancient systems.


Atila


IFTI with template alias fails in D, works in C++

2015-08-12 Thread Timothee Cour via Digitalmars-d-learn
main.d:
--
struct A(T, int D) {
  this(string ignore){}
}

alias B(T)=A!(T, 1);

void fun1(T)(A!(T,1) a) { }
void fun2(T)(B!T a) { }

unittest{
  auto a=A!(double,1)(a);
  assert(is(typeof(a) == B!double));
  fun1(a);//ok

  fun2!double(a);//ok

  // no IFTI here:
  //fun2(a);//not ok:
  //fun2 cannot deduce function from argument types !()(A!(double, 1)),
candidates are...
}
--


C++ works fine here:


main.cc:
--
templateclass T, int D
class A {
};

template class T
using B = AT, 1;

template class T
void fun(BT a) { }

void test(){
  Adouble,1a;
  fun(a);
}
--

I can use a workaround but it makes the code uglier. What's the recommended
way around this?
Could we support this as in C++?


Re: dmd.conf... again

2015-08-12 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 12:16:50 UTC, Atila Neves wrote:
I'm trying to use dmd on a VM where I don't have root 
privileges (don't ask). I can't copy dmd.conf to /etc.


If you use the dmd zip, everything just works when you just unzip 
it and use it all in-place. No need to move or copy files 
anywhere, no need for root.




Re: Convert a hex color string into r,g,b components.

2015-08-12 Thread wobbles via Digitalmars-d-learn

On Tuesday, 11 August 2015 at 22:11:51 UTC, Marcin Szymczak wrote:

I would really love to solve this problem using ranges, because 
i am learning how to use them. Unfortunately even such a simple 
task seems so hard for me ;(


I think writing a simple function to parse a string into a Color 
would be best here.


Color parseRGBString(string theString){
if(theString.length != 7)
throw new Exception(Error. Cannot parse to 
color:  ~ theString);

return Color(
to!ubyte(theString[1..3], 16),
to!ubyte(theString[3..5], 16),
to!ubyte(theString[5..7], 16)
);
}

I could probably do more to ensure that the string actually does 
represent a color (e.g. Check if no char is  F etc).


Also, using ranges isn't always required, theres no such thing as 
a too simple solution, as long as it works!


You can use this in a range then, e.g. say the user passes in 
lots of strings to your program, you can


listOfColors.map!(a = a.parseRGBString); // and now you have a 
lazily evaluated list of Color objects.


Re: dmd.conf... again

2015-08-12 Thread Dicebot via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 13:04:25 UTC, Atila Neves wrote:

On Wednesday, 12 August 2015 at 12:29:46 UTC, Dicebot wrote:

More info about what gets placed where please.

I have special dev layout on my system that co-exists with 
system-wide installation of dmd. It is as simple as having 
~/dlang/{dmd|druntime|phobos}, linking ~/dlang/dmd/src/dmd to 
~/bin/dmd-dev and placing dmd.conf in ~/bin which adds all 
those paths as -I and -L flags. Works just fine.


There's no system-wide installation (since I don't have root), 
I just downloaded the zip for 2.068 and added dmd2/linux/bin64 
to my PATH.


Atila


Yeah I have meant that it works _even_ if you also have 
system-wide installation. No idea what dmd.conf they put into zip 
- I never use it.


Re: Code Reviewer

2015-08-12 Thread Clayton via Digitalmars-d-learn
On Wednesday, 12 August 2015 at 02:49:59 UTC, Rikki Cattermole 
wrote:

On 12/08/2015 10:50 a.m., Clayton wrote:

Hello everyone,

Am looking for someone who could help review my code . As an 
entry
exercise to D am converting  3 C implementations of popular 
pattern
matching algorithms. The idea is to have 6 final 
implementations ( 3
compile-time and 3 runtime) . I think am basically done with 
the coding,
but being a beginner myself, I feel I need some do some 
critics so I can

improve (especially on the compiletime ones).

I could have uploaded direct but I think the code may be way 
too long.


Help will be dearly appreciated.


Upload to e.g. Github/gist/pastebin.


Hi Rikki, can I have your email so I add you to my repository on 
BitBucket?


Re: Code Reviewer

2015-08-12 Thread Rikki Cattermole via Digitalmars-d-learn

On 13/08/2015 12:09 a.m., Clayton wrote:

On Wednesday, 12 August 2015 at 02:49:59 UTC, Rikki Cattermole wrote:

On 12/08/2015 10:50 a.m., Clayton wrote:

Hello everyone,

Am looking for someone who could help review my code . As an entry
exercise to D am converting  3 C implementations of popular pattern
matching algorithms. The idea is to have 6 final implementations ( 3
compile-time and 3 runtime) . I think am basically done with the coding,
but being a beginner myself, I feel I need some do some critics so I can
improve (especially on the compiletime ones).

I could have uploaded direct but I think the code may be way too long.

Help will be dearly appreciated.


Upload to e.g. Github/gist/pastebin.


Hi Rikki, can I have your email so I add you to my repository on BitBucket?


No need, as long as it is not propriety code feel free to post the links :)
That way anybody who is willing to comment can.


dmd.conf... again

2015-08-12 Thread Atila Neves via Digitalmars-d-learn
I'm trying to use dmd on a VM where I don't have root privileges 
(don't ask). I can't copy dmd.conf to /etc. According to the 
docs, I should be able to use a dmd.conf that's in the same dir 
as dmd itself, or in my home directory, or even specifying 
-conf=. None of these seems to tell dmd where to find phobos.


I've also tried setting DFLAGS myself, but under no circumstances 
is dmd passing the -L where phobos is to ld, so I can compile but 
not link (well, I can if I use gcc!). Also tried dmd 
-L-L/path/to/phobos.


Does anyone have a clue why this doesn't work? My dmd.conf looks 
like this:


[Environment]
DFLAGS=-I/nobackup/dlang/phobos/ 
-I/nobackup/dlang/druntime/import 
-L-L/nobackup/dlang/download/dmd2/linux/lib64


Atila


Re: dmd.conf... again

2015-08-12 Thread via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 12:16:50 UTC, Atila Neves wrote:
I'm trying to use dmd on a VM where I don't have root 
privileges (don't ask). I can't copy dmd.conf to /etc. 
According to the docs, I should be able to use a dmd.conf 
that's in the same dir as dmd itself, or in my home directory, 
or even specifying -conf=. None of these seems to tell dmd 
where to find phobos.


I've also tried setting DFLAGS myself, but under no 
circumstances is dmd passing the -L where phobos is to ld, so I 
can compile but not link (well, I can if I use gcc!). Also 
tried dmd -L-L/path/to/phobos.


Does anyone have a clue why this doesn't work? My dmd.conf 
looks like this:


[Environment]
DFLAGS=-I/nobackup/dlang/phobos/ 
-I/nobackup/dlang/druntime/import 
-L-L/nobackup/dlang/download/dmd2/linux/lib64


Atila


Hmm, for me the dmd zip works out of the box. Unzip, add 
...dmd2/linux/bin64 to PATH. Done.


(The following is a stupid workaround that may be employed for 
libs that don't follow the normal naming convention. Phobos 
shouldn't be one of them but...)
But lets say you want to force it to link to a specific lib that 
is in a lookup path you could use the full filename: 
-L-l:libphobos2.so


Re: dmd.conf... again

2015-08-12 Thread Rikki Cattermole via Digitalmars-d-learn

On 13/08/2015 12:16 a.m., Atila Neves wrote:

I'm trying to use dmd on a VM where I don't have root privileges (don't
ask). I can't copy dmd.conf to /etc. According to the docs, I should be
able to use a dmd.conf that's in the same dir as dmd itself, or in my
home directory, or even specifying -conf=. None of these seems to tell
dmd where to find phobos.

I've also tried setting DFLAGS myself, but under no circumstances is dmd
passing the -L where phobos is to ld, so I can compile but not link
(well, I can if I use gcc!). Also tried dmd -L-L/path/to/phobos.

Does anyone have a clue why this doesn't work? My dmd.conf looks like this:

[Environment]
DFLAGS=-I/nobackup/dlang/phobos/ -I/nobackup/dlang/druntime/import
-L-L/nobackup/dlang/download/dmd2/linux/lib64

Atila


Perhaps this small snippet from my Windows install might shred some 
light. Specifically the LIB property.


[Environment32]
LIB=%@P%\..\lib
LINKCMD=%@P%\link.exe


[Environment64]
LIB=%@P%\..\lib64


Re: dmd.conf... again

2015-08-12 Thread Dicebot via Digitalmars-d-learn

More info about what gets placed where please.

I have special dev layout on my system that co-exists with 
system-wide installation of dmd. It is as simple as having 
~/dlang/{dmd|druntime|phobos}, linking ~/dlang/dmd/src/dmd to 
~/bin/dmd-dev and placing dmd.conf in ~/bin which adds all those 
paths as -I and -L flags. Works just fine.





Re: dmd.conf... again

2015-08-12 Thread Atila Neves via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 12:29:46 UTC, Dicebot wrote:

More info about what gets placed where please.

I have special dev layout on my system that co-exists with 
system-wide installation of dmd. It is as simple as having 
~/dlang/{dmd|druntime|phobos}, linking ~/dlang/dmd/src/dmd to 
~/bin/dmd-dev and placing dmd.conf in ~/bin which adds all 
those paths as -I and -L flags. Works just fine.


There's no system-wide installation (since I don't have root), I 
just downloaded the zip for 2.068 and added dmd2/linux/bin64 to 
my PATH.


Atila


Re: dmd.conf... again

2015-08-12 Thread Atila Neves via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 12:40:49 UTC, Adam D. Ruppe wrote:

On Wednesday, 12 August 2015 at 12:16:50 UTC, Atila Neves wrote:
I'm trying to use dmd on a VM where I don't have root 
privileges (don't ask). I can't copy dmd.conf to /etc.


If you use the dmd zip, everything just works when you just 
unzip it and use it all in-place. No need to move or copy files 
anywhere, no need for root.


I downloaded the zip, added linux/bin64 to PATH, tried compiling 
a hello world and got:


usr/bin/ld: cannot find -l:libphobos2.a

That's when I started trying to set the configuration but nothing 
seems to work.


Atila


Re: Code Reviewer

2015-08-12 Thread sigod via Digitalmars-d-learn

On Tuesday, 11 August 2015 at 22:50:52 UTC, Clayton wrote:

Hello everyone,

Am looking for someone who could help review my code . As an 
entry exercise to D am converting  3 C implementations of 
popular pattern  matching algorithms. The idea is to have 6 
final implementations ( 3 compile-time and 3 runtime) . I think 
am basically done with the coding, but being a beginner myself, 
I feel I need some do some critics so I can improve (especially 
on the compiletime ones).


I could have uploaded direct but I think the code may be way 
too long.


Help will be dearly appreciated.


Use this site: http://codereview.stackexchange.com/


Re: dmd.conf... again

2015-08-12 Thread Atila Neves via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 13:46:24 UTC, wobbles wrote:

On Wednesday, 12 August 2015 at 13:00:45 UTC, Atila Neves wrote:
On Wednesday, 12 August 2015 at 12:40:49 UTC, Adam D. Ruppe 
wrote:
On Wednesday, 12 August 2015 at 12:16:50 UTC, Atila Neves 
wrote:

[...]


If you use the dmd zip, everything just works when you just 
unzip it and use it all in-place. No need to move or copy 
files anywhere, no need for root.


I downloaded the zip, added linux/bin64 to PATH, tried 
compiling a hello world and got:


usr/bin/ld: cannot find -l:libphobos2.a

That's when I started trying to set the configuration but 
nothing seems to work.


Atila


Have you run dmd from the directory you unzipped it to?
libphobos2.a is in there I think, so ld wouldn't be able to 
find it.


Just did, didn't work. Tried it from lib64 and lib32 as well, 
nothing.


Atila


Re: dmd.conf... again

2015-08-12 Thread wobbles via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 13:00:45 UTC, Atila Neves wrote:
On Wednesday, 12 August 2015 at 12:40:49 UTC, Adam D. Ruppe 
wrote:
On Wednesday, 12 August 2015 at 12:16:50 UTC, Atila Neves 
wrote:
I'm trying to use dmd on a VM where I don't have root 
privileges (don't ask). I can't copy dmd.conf to /etc.


If you use the dmd zip, everything just works when you just 
unzip it and use it all in-place. No need to move or copy 
files anywhere, no need for root.


I downloaded the zip, added linux/bin64 to PATH, tried 
compiling a hello world and got:


usr/bin/ld: cannot find -l:libphobos2.a

That's when I started trying to set the configuration but 
nothing seems to work.


Atila


Have you run dmd from the directory you unzipped it to?
libphobos2.a is in there I think, so ld wouldn't be able to find 
it.


tharsis.prof tests are broken with dmd 2.068

2015-08-12 Thread extrawurst via Digitalmars-d-learn
Hi guys, i am having no luck to fix the bug causing kiith-sa 
project tharsis.prof to successfully build with unittests:


https://github.com/kiith-sa/tharsis.prof/issues/2

the actual compiler error says:

```
C:\_apps\D\dmd2\windows\bin\..\..\src\phobos\std\range\package.d(7180,24): 
Error: 'tharsis.prof.ranges.__unittestL516_25.SortedRange!(RangeT!(Array!(Z
oneData)), __lambda2).SortedRange.dbgVerifySorted' is not nothrow
C:\_apps\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm\sorting.d(982,29): 
Error: template instance tharsis.prof.ranges.__unittestL516_25.assumeSor
ted!(__lambda2, RangeT!(Array!(ZoneData))) error instantiating
source\tharsis\prof\ranges.d(565,8):instantiated from 
here: sort!((a, b) = a.duration  b.duration, 
cast(SwapStrategy)0, RangeT!(Array!(ZoneD

ata)))
```

and the code causing this is:

```
auto topLevelArray = Array!ZoneData(topLevel);
topLevelArray[].sort!((a, b) = a.duration  b.duration);
```


Re: Does D have syntax for adding subscopes to classes?

2015-08-12 Thread Xinok via Digitalmars-d-learn

On Wednesday, 12 August 2015 at 15:47:37 UTC, Adam D. Ruppe wrote:

Example with them:
...


That's the idea I had except I would use a struct instead because 
using a class requires a second allocation.


Re: dmd.conf... again

2015-08-12 Thread Ali Çehreli via Digitalmars-d-learn

On 08/12/2015 08:38 AM, Adam D. Ruppe wrote:

On Wednesday, 12 August 2015 at 15:30:09 UTC, Atila Neves wrote:

I've never seen a colon in library options before and the (ancient)
gcc on the system doesn't seem to like it one bit.


ohhh, I have seen that before, I was on a CentOS 5 VM and it didn't
like that colon either. It was added to dmd about two or three years
ago, I remember it breaking my thing.

I think I 'fixed' it by just linking manually in the makefile for that vm.



This thread explains the same problem I've been having on my Scientific 
Linux 6.1 even though my 'man ld' talks about :filename.


Ali