Dlangui can't build x64 example1.exe , because the size_t is ulong on winx64

2014-05-03 Thread FrankLike via Digitalmars-d-learn

Hi,everyone,

I build the dlangui on win7 x64,use the debug win32,it can get 
the example1.exe,

but use the debug x64,not get the exe file,the error is
	Error: function pointer FreeImage_OpenMemory (ubyte* data = 
null, uint size_in_bytes = 0u) is not callable using argument 
types (ubyte*, 
ulong)	x:\GitHub\dlangui\src\dlangui\graphics\images.d	93	


the reason is the function 'FreeImage_OpenMemory',
it decalres that 'alias da_FreeImage_OpenMemory = FIMEMORY* 
function( BYTE* data = null, DWORD size_in_bytes = 0 )' ,but it's 
args is ulong.


if the size_t not change on x64,and add the new 'longlength' 
maybe a good idea.
Many Projects want to move on x64,but must modify the error 
'size_t  is ulong'.

Then stop to do. if the size_t is not change,  maybe a good idea.

Frank.


Re: Dlangui can't build x64 example1.exe , because the size_t is ulong on winx64

2014-05-03 Thread Rikki Cattermole via Digitalmars-d-learn

On Saturday, 3 May 2014 at 08:59:40 UTC, FrankLike wrote:

Hi,everyone,

I build the dlangui on win7 x64,use the debug win32,it can get 
the example1.exe,

but use the debug x64,not get the exe file,the error is
	Error: function pointer FreeImage_OpenMemory (ubyte* data = 
null, uint size_in_bytes = 0u) is not callable using argument 
types (ubyte*, 
ulong)	x:\GitHub\dlangui\src\dlangui\graphics\images.d	93	


the reason is the function 'FreeImage_OpenMemory',
it decalres that 'alias da_FreeImage_OpenMemory = FIMEMORY* 
function( BYTE* data = null, DWORD size_in_bytes = 0 )' ,but 
it's args is ulong.


if the size_t not change on x64,and add the new 'longlength' 
maybe a good idea.
Many Projects want to move on x64,but must modify the error 
'size_t  is ulong'.
Then stop to do. if the size_t is not change,  maybe a good 
idea.


Frank.


Yes size_t is ulong on 64bits and uint of 32bit. Why would you 
need a new type?
If you want it ulong or uint make it so. It should be implicit 
the conversion between uint and ulong.


In the example you gave, I believe you should file a bug report 
with the developers.


Re: Math-Parser

2014-05-03 Thread Rikki Cattermole via Digitalmars-d-learn
On Friday, 2 May 2014 at 22:34:48 UTC, Tim Holzschuh via 
Digitalmars-d-learn wrote:

Hi there,

I currently try to write a simple math-parser in D.

However.. something isn't working and I just can't figure out 
what's the problem.
(I'm relative new to D, and this is my first test to write a 
parser/lexer)


I'm pretty sure it's a simple layer-8-problem, but I always 
overlook it.


While the Lexer seems to work, the Parser just sets _index - 0
(and I don't understand why..).

If you would take a look at [1], I'd be very thankful..

Most probably this isn't a wrong use of something D-specific, 
it's more like I am stuck..^^


Thank you,
Tim

[1]: https://github.com/tholzschuh/math-parser


General suggestions:
Don't commit the build ext. files along with source code and in 
this case they aren't needed. Mono-D can load dub.json straight. 
As well as the obj/bin directories.


With regards to your issues I have a suspicion about it being how 
your parse the tokens. Within the parser.

Without really trying out atleast thats what I'm guessing.


Re: Math-Parser

2014-05-03 Thread Timon Gehr via Digitalmars-d-learn

On 05/03/2014 12:34 AM, Tim Holzschuh via Digitalmars-d-learn wrote:


Most probably this isn't a wrong use of something D-specific


Some of the problems are:

@property Lexer lexer() pure { return _lexer; }

If you change the result of a call to 'lexer' this will not change 
'_lexer'. Mark the property 'ref' or get rid of it



if( !previous  !token.type == TokenType.end )
popFront();

=

if(!previous  token.type != TokenType.end) popFront();


Let me know if you also want hints on how to get the logic right.


Re: Postblit not invokable with MyStruct(MyStruct()); ?

2014-05-03 Thread Artur Skawina via Digitalmars-d-learn
On 05/03/14 01:05, Mark Isaacson via Digitalmars-d-learn wrote:
 2) I ran into this issue while attempting to leverage the postblit for 
 code-reuse. In particular, I have a setup that is similar to:
 
 struct A {
   this(B b) { /* Stuff */ }
 }
 
 struct B {
 }
 
 void foo(T)(T param) {
   auto a = A(param);
   /* Stuff */
 }
 
 unittest {
   foo(A()); //Fails
   foo(B()); //Succeeds
 }
 
 The notion being that A and B are 2 ways to represent the same thing, why not 
 convert everything to the A format and proceed from there; I figured the 
 compiler would optimize out the pointless copy when T == A. Alas, as shown in 
 my unittest, foo fails to accept arguments of type A.

What actually fails is the initialization of 'a'.
Add another

   this(A a) { /* Stuff */ }

constructor to the 'A' struct, and it will work.


And, yes, the missing cpctors are a language problem.

artur


ncurses linking(?) problem on Mac OS X

2014-05-03 Thread Joakim via Digitalmars-d-learn

Hi,

I am very new to D, I just started with it a week ago or so, and
I haven't really been using compiled languages before (except for
Java), so I'm pretty confused with the whole thing in general. ;)

I try to use the ncurses library in my project using:


dependencies : {
 ncurses : ~master
},
lflags : [-v]


But when I try to compile it, I get the following:


@(#)PROGRAM:ld  PROJECT:ld64-236.4
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64
armv6m armv7m armv7em
Library search paths:
/usr/share/dmd/lib
/usr/lib
/usr/local/lib
Framework search paths:
/Library/Frameworks/
/System/Library/Frameworks/
ld: library not found for -lncursesw
clang: error: linker command failed with exit code 1 (use -v to
see invocation)
--- errorlevel 1
FAIL
.dub/build/application-debug-posix.osx-x86_64-dmd-4349FBA7803F9504BC9BF29263B86A68
text edit executable
Error executing command build: Link command failed with exit code
1
  Terminated, exit code: 2  


I have no idea where to go from here to be honest. It's probably
something easily fixed for someone even a tiny bit more
experienced.

I would love some help if anyone feels up to it.


Re: Error 42: Symbol Undefined for asserts

2014-05-03 Thread FrankLike via Digitalmars-d-learn


The problem I am running in to now is that Xamarin Studio now 
launches Test.pdb.exe which doesn't seem to do anything at all.


Use  visual d,it's simple for using pdb.exe


Re: ncurses linking(?) problem on Mac OS X

2014-05-03 Thread Mike Parker via Digitalmars-d-learn

On 5/3/2014 9:36 PM, Joakim wrote:


  Terminated, exit code: 2  


I have no idea where to go from here to be honest. It's probably
something easily fixed for someone even a tiny bit more
experienced.

I would love some help if anyone feels up to it.


Have you actually installed ncurses on your system?

https://gist.github.com/cnruby/960344


Re: Error 42: Symbol Undefined for asserts

2014-05-03 Thread Andre Steenveld via Digitalmars-d-learn

On Saturday, 3 May 2014 at 13:18:13 UTC, FrankLike wrote:


The problem I am running in to now is that Xamarin Studio now 
launches Test.pdb.exe which doesn't seem to do anything at all.


Use  visual d,it's simple for using pdb.exe


Which isn't really an option, Visual D is for Visual Studio and 
the express versions of VS don't allow 3rd party extensions. Also 
I am convinced it has something to do with Mono-D because 
debugging does work most of the time.


Re: ncurses linking(?) problem on Mac OS X

2014-05-03 Thread Joakim via Digitalmars-d-learn

Have you actually installed ncurses on your system?

https://gist.github.com/cnruby/960344


I will try this, but I did a search/info with homebrew and it 
said it was not recommended because OS X already has ncurses 
installed by default. Something about conflicts that could 
possibly occur. I found libncurses.dylib and such already 
installed in /usr/lib.


Re: ncurses linking(?) problem on Mac OS X

2014-05-03 Thread Joakim via Digitalmars-d-learn

It worked perfecly. I knew I had missed something stupid. :)

What confused me was the homebrew warning.

Thank you for helping a newbie out. :)


Re: *** GMX Spamverdacht *** Re: Math-Parser

2014-05-03 Thread Tim Holzschuh via Digitalmars-d-learn

Am 03.05.2014 11:17, schrieb Rikki Cattermole via Digitalmars-d-learn:

General suggestions:
Don't commit the build ext. files along with source code and in this 
case they aren't needed. Mono-D can load dub.json straight. As well as 
the obj/bin directories.



Yeah you're right, thank you.
(And thank your for the Mono-D, dub thing, didn't know that..)

Tim


Re: Math-Parser

2014-05-03 Thread Tim Holzschuh via Digitalmars-d-learn

Am 03.05.2014 13:29, schrieb Timon Gehr via Digitalmars-d-learn:

@property Lexer lexer() pure { return _lexer; }

If you change the result of a call to 'lexer' this will not change 
'_lexer'. Mark the property 'ref' or get rid of it


How did I forget about Lexer being a struct is a value type...?
Thank you!


if( !previous  !token.type == TokenType.end )
popFront();


My favourite. *g*


Let me know if you also want hints on how to get the logic right.

Would be very nice!
While 2*2 works, 2+2 throws an Error because the number-method gets an 
END-Token instead of a Number-Token (although I'm not sure why).


Thank you,
Tim


Re: Math-Parser

2014-05-03 Thread Timon Gehr via Digitalmars-d-learn

On 05/03/2014 08:20 PM, Tim Holzschuh via Digitalmars-d-learn wrote:



Let me know if you also want hints on how to get the logic right.

Would be very nice!
While 2*2 works, 2+2 throws an Error because the number-method gets an
END-Token instead of a Number-Token (although I'm not sure why).

Thank you,
Tim


Get rid of 'revert' and implement the parser in terms of range 
primitives. (The first thing you do in the while loops should be a 
popFront().)


Re: Postblit not invokable with MyStruct(MyStruct()); ?

2014-05-03 Thread Mark Isaacson via Digitalmars-d-learn



What actually fails is the initialization of 'a'.
Add another

   this(A a) { /* Stuff */ }

constructor to the 'A' struct, and it will work.


And, yes, the missing cpctors are a language problem.

artur



Thanks. Yeah, I figured I could do that, I was just hoping that I 
could leverage the postblit.


Ultimately my answer to my second question became: Calling the 
postblit directly is far too low level, just use std.conv.to 
instead. to!A(x) did exactly the right thing (without any 
modification of the original classes I think).


Error

2014-05-03 Thread Martin Bossard via Digitalmars-d-learn

I tried the following:

dub install derelict

but i only received the following error

The 'install' Command was renamed to 'fetch'. Please update your
scripts.
Getting a release version failed: No package derelict was found
matching the dependency =0.0.0
Retry with ~master...
Fetching derelict ~master...
Error executing command install: Couldn't resolve host name on
handle D20220

Trying the fetch command leads to the same error. I hope somebody
can help me.

Thanks,

Martin


map!(char)(string) problem

2014-05-03 Thread David Held via Digitalmars-d-learn

import std.algorithm;

int toInt(char c) { return 1; }

void main()
{
map!(a = toInt(a))(hello);
}

Can someone please explain why I get this:

Bug.d(10): Error: function Bug.toInt (char c) is not callable using 
argument types (dchar)

^^^
D:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(425): Error: 
template instance Bug.main.__lambda1!dchar error instantiating
D:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(411): 
instantiated from here: MapResult!(__lambda1, string)

Bug.d(10):instantiated from here: map!string
D:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(411): Error: 
template instance Bug.main.MapResult!(__lambda1, string) error instantiating

Bug.d(10):instantiated from here: map!string
Bug.d(10): Error: template instance Bug.main.map!((a) = 
toInt(a)).map!string error instantiating


I thought that string == immutable char[], but this implies that it is 
getting inferred as dchar[], I guess.


Dave


Re: map!(char)(string) problem

2014-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 03 May 2014 14:47:56 -0700
David Held via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:

 import std.algorithm;
 
 int toInt(char c) { return 1; }
 
 void main()
 {
  map!(a = toInt(a))(hello);
 }
 
 Can someone please explain why I get this:
 
 Bug.d(10): Error: function Bug.toInt (char c) is not callable using 
 argument types (dchar)
 ^^^
 D:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(425): Error: 
 template instance Bug.main.__lambda1!dchar error instantiating
 D:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(411): 
 instantiated from here: MapResult!(__lambda1, string)
 Bug.d(10):instantiated from here: map!string
 D:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(411): Error: 
 template instance Bug.main.MapResult!(__lambda1, string) error
 instantiating Bug.d(10):instantiated from here: map!string
 Bug.d(10): Error: template instance Bug.main.map!((a) = 
 toInt(a)).map!string error instantiating
 
 I thought that string == immutable char[], but this implies that it
 is getting inferred as dchar[], I guess.

All strings are treated as ranges of dchar by Phobos.

http://stackoverflow.com/questions/12288465

If you really want to operate on strings as ranges of code units rather
than code points, then you need to use std.string.representation and
convert them to the equivalent integral types (e.g. immutable(ubyte)[]).


- Jonathan M Davis


Conversion and Assignment on EnumUnion and EnumChain

2014-05-03 Thread Nordlöw
I've put up a module 
https://github.com/nordlow/justd/blob/master/enums.d


that provides two type constructors

- EnumChain
- EnumUnion

that can be used to combine names or names-and-values from one or 
more enums.


I would now like to define rules for assignments and implicit 
conversions with the following checks


- Assignment to EnumUnion, EnumChain from its parts is always 
nothrow.

- Assignment from EnumUnion, EnumChain to its parts may throw.

to emulate Ada's subtype.

Is it currently possible to implement any of these?

Also do you think the namings EnumChain and EnumUnion are correct?