Re: Imports incorrectly part of "allMembers" trait output?

2017-01-02 Thread bauss via Digitalmars-d-learn

On Monday, 2 January 2017 at 18:56:40 UTC, Mike Bierlee wrote:

When compiling the following code with DMD 2.072.2:

class LeClass {
import std.stdio;
}

void main() {
foreach (memberName; __traits(allMembers, LeClass)) {
pragma(msg, memberName);
}
}

The following output is shown in the console:

std
toString
toHash
opCmp
opEquals
Monitor
factory

Note how "std" is part of the output of allMembers. Is this a 
bug or is this intended behavior? I don't think imports are 
necessarily members of a class. It also happens for static 
imports.


It seems to be a bug that it takes std as there's no std as a 
part of object, not even as an import.


However there is: __traits(derivedMembers, T) which should only 
give you members of your actual class and not anything inherited 
from base classes and/or object.


Re: Android Status

2017-01-02 Thread Joakim via Digitalmars-d-learn

On Monday, 2 January 2017 at 11:47:52 UTC, Ignacious wrote:

On Monday, 2 January 2017 at 03:08:10 UTC, Joakim wrote:

On Sunday, 1 January 2017 at 09:34:24 UTC, Ignacious wrote:


Can you try

sudo apt-get install libconfig9

I don't know if that will install something different, but 
it's the command I see others using online.  Otherwise, 
check if the libconfig++9 package you installed included 
libconfig.so.9, which is what ldc is linked against.  If 
not, install the package that provides that library.  The 
wiki mentions installing libconfig-dev, you could always 
just install that if nothing else works.





That is what I used to get it on there in the first place... 
but the ldc compiler still could not find it.


The problem seems to be where ldc2 is looking for 
libconfig.so.9 rather than it being installed or not.


How do I either know where it is looking for where to put it?


You said you installed libconfig++9, which an apt search shows 
me is a different package than libconfig9, that includes a 
library named differently.  As I said, are you sure that 
particular libconfig.so.9 library is installed?


If it is, manually adding its path to LD_LIBRARY_PATH is the 
way to make sure it's found.


Ok, I didn't realize they were different packages.

I now get the error

./bin/ldmd2: error while loading shared libraries: 
libncursesw.so.6: cannot open shared object file: No such file 
or directory


and trying to install libncursesw is missing. I tried 
installing libncurses5 and it worked, but, of course, not 
version 6 or whatever. tried various things... nothing works.


./bin/ldc2: error while loading shared libraries: 
libncursesw.so.6: cannot open shared object file: No such file 
or directory


I downloaded the sources. I had to install gcc, make, then I 
did ./configure --enable-widec 
(http://arstechnica.com/civis/viewtopic.php?f=20&t=1161942), 
then ran make.. I end up getting the errors


make[1]: Leaving directory `/mnt/b/c/test'
cd misc && make DESTDIR="" all
make[1]: Entering directory `/mnt/b/c/misc'
WHICH_XTERM=xterm-new \
ticdir=/usr/share/terminfo \
/bin/sh ./gen_edit.sh >run_tic.sed
echo '** adjusting tabset paths'
** adjusting tabset paths
sed -f run_tic.sed ../misc/terminfo.src >terminfo.tmp
make[1]: Leaving directory `/mnt/b/c/misc'
cd c++ && make DESTDIR="" all
make[1]: Entering directory `/mnt/b/c/c++'
cp ./etip.h.in etip.h
sh ./edit_cfg.sh ../include/ncurses_cfg.h etip.h
substituting autoconf'd values from ../include/ncurses_cfg.h 
into etip.h

... CPP_HAS_PARAM_INIT 0
... CPP_HAS_STATIC_CAST 0
... ETIP_NEEDS_MATH_EXCEPTION 0
... ETIP_NEEDS_MATH_H 0
... HAVE_BUILTIN_H 0
... HAVE_GPP_BUILTIN_H 0
... HAVE_GXX_BUILTIN_H 0
... HAVE_IOSTREAM 0
... HAVE_TYPEINFO 0
... HAVE_VALUES_H 0
... IOSTREAM_NAMESPACE 0
cd ../objects;   -I../c++ -I../include -I. -DHAVE_CONFIG_H  
-D_GNU_SOURCE -DNDEBUG -I. -I../include  -c ../c++/cursesf.cc

/bin/sh: 1: -I../c++: not found
make[1]: *** [../objects/cursesf.o] Error 127
make[1]: Leaving directory `/mnt/b/c/c++'
make: *** [all] Error 2

So, now I do not know what to do next.


Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libncurses6

(This is why I hate working linux, so much obfuscation... so 
many potential points of failure)


Yeah, not a good idea to build from source yourself.  Try the 
advice here, ie see if you can install a package with that 
library or just symlink to the older library if not:


http://askubuntu.com/questions/771047/erlang-error-while-loading-shared-libraries-libncursesw-so-6

Every system has these problems, whether Windows, linux, or OS X. 
Linux makes it really easy to install packages and libraries, but 
then you can hit this issue where Debian/Ubuntu doesn't provide 
the latest versions of packages like Arch does, which is where I 
compiled the cross-compiler.


Also, once I go through all this trouble, I have to do it again 
for the arm verson(using x86-64 ldc)? Can I install on the same 
system or will the libraries conflict and I'll have to go 
through all this mess again?


I'm not sure what you mean, there is no other ARM version.  All 
you have to do is download the cross-compiler and run it.  The 
cross-compiler is a linux/x64 binary that comes with a 
pre-compiled standard library for ARM.  Once you can run this 
cross-compiler build I provided, by setting up the needed 
libraries, you should be able to build Android binaries or apks 
just by using the cross-compiler, by following these instructions:


http://wiki.dlang.org/Build_LDC_for_Android#Build_a_command-line_executable
http://wiki.dlang.org/Build_LDC_for_Android#Build_a_sample_OpenGL_Android_app_ported_to_D

However, you will also want to install the Android SDK for 
Windows, which requires Java, if you want to build an apk in the 
usual way, as mentioned in the wiki:


http://developer.android.com/sdk/index.html

Alternately, you could package an apk from sc

Re: String characters not extended

2017-01-02 Thread bauss via Digitalmars-d-learn

On Monday, 2 January 2017 at 21:07:37 UTC, Ignacious wrote:
when one prints out a string with some extended(I guess it's 
unicode), writeln prints out the ascii versions that do not 
correspond to what they really are. e.g., an umlaut is printed 
out as 1/2 or something.


how to get it to print the correct codes?


Most likely not an issue with D, but your console's display 
encoding. Else your standard output might have ASCII as encoding 
and then you'd have to change it.


What OS are you on?


Re: String characters not extended

2017-01-02 Thread Nicholas Wilson via Digitalmars-d-learn

On Monday, 2 January 2017 at 21:07:37 UTC, Ignacious wrote:
when one prints out a string with some extended(I guess it's 
unicode), writeln prints out the ascii versions that do not 
correspond to what they really are. e.g., an umlaut is printed 
out as 1/2 or something.


how to get it to print the correct codes?


It should Just work. can you paste the source and output?




String characters not extended

2017-01-02 Thread Ignacious via Digitalmars-d-learn
when one prints out a string with some extended(I guess it's 
unicode), writeln prints out the ascii versions that do not 
correspond to what they really are. e.g., an umlaut is printed 
out as 1/2 or something.


how to get it to print the correct codes?


Imports incorrectly part of "allMembers" trait output?

2017-01-02 Thread Mike Bierlee via Digitalmars-d-learn

When compiling the following code with DMD 2.072.2:

class LeClass {
import std.stdio;
}

void main() {
foreach (memberName; __traits(allMembers, LeClass)) {
pragma(msg, memberName);
}
}

The following output is shown in the console:

std
toString
toHash
opCmp
opEquals
Monitor
factory

Note how "std" is part of the output of allMembers. Is this a bug 
or is this intended behavior? I don't think imports are 
necessarily members of a class. It also happens for static 
imports.


Re: Variadic function parameters passed by move

2017-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, December 21, 2016 23:18:29 Nordlöw via Digitalmars-d-learn 
wrote:
> Do you have any clue on how to most easily find detect whether a
> SymbolExpression is the last reference to that symbol in the
> scope of the symbol definition, Jonathan?

Sorry, but my knowledge of dmd's internals is pretty poor. I'm somewhat
familiar with the lexer, but that's about it.

- Jonathan M Davis




Re: Standard output does not get flushed in cygwin?

2017-01-02 Thread Adam D. Ruppe via Digitalmars-d-learn

On Monday, 2 January 2017 at 15:38:20 UTC, Anonymouse wrote:
Maybe I'll just have to paste version (Windows) stdout.flush() 
everywhere. Or maybe I can hijack calls to my own writeln 
wrapper.


It comes from the C library thinking those other consoles are 
pipes instead of consoles, and thus block buffering instead of 
line buffering.


Easy fix is to just flush after each line... actually, IMO, the 
top-level writeln should just always do this since it is one of 
the most common FAQs.


Re: Standard output does not get flushed in cygwin?

2017-01-02 Thread Anonymouse via Digitalmars-d-learn

On Sunday, 1 January 2017 at 13:04:30 UTC, rikki cattermole wrote:

What is your terminal emulator?
Poderosa has a known problem for this.
Where as ConEmu (which I have since moved over to) works fine.

Fun fact, I had a similar file to the yours in /tmp/test.d :)


The default mintty.

I tried ConEmu now and it works with cygwin's bash shell! But 
then mosh and tmux break, unless I use the cygwin terminal 
connector[1], with which I get the same results as earlier.


Maybe I'll just have to paste version (Windows) stdout.flush() 
everywhere. Or maybe I can hijack calls to my own writeln wrapper.



[1]: https://conemu.github.io/en/CygwinMsysConnector.html


Mysql-native - full database backup

2017-01-02 Thread Geert via Digitalmars-d-learn

Hi!

How can i create a full database backup using mysql-native for D?

https://github.com/mysql-d/mysql-native


Thanks!


Re: DIP-1000 and return

2017-01-02 Thread Nordlöw via Digitalmars-d-learn

On Monday, 2 January 2017 at 14:38:53 UTC, Nordlöw wrote:
I've tried as many combinations of `return` and `scope` as I 
can think of such as


Update:

Qualifying `asStatic` with `@safe pure nothrow @nogc` as

T[length] asStatic(T, size_t length)(T[length] arr)
@safe pure nothrow @nogc
{
return arr;
}

makes

@safe pure nothrow @nogc unittest
{
auto x = [1, 2, 3].asStatic;
static assert(is(typeof(x) == int[x.length]));
static assert(is(typeof([1, 2, 3].asStatic) == 
int[x.length]));

}

compile. Also

T[length] asStatic(T, size_t length)(scope T[length] arr)
@safe pure nothrow @nogc
{
return arr;
}

works. Is with or without `scope` preferred here?

Seems to be some problem with template qualifier inference. 
Should I file a bug report?


Re: DIP-1000 and return

2017-01-02 Thread Nordlöw via Digitalmars-d-learn

On Sunday, 1 January 2017 at 18:00:54 UTC, Stefan Koch wrote:


Try:
 auto asStatic(T, size_t length)(scope T[length] arr)
 {
 return arr;
 }


I've tried as many combinations of `return` and `scope` as I can 
think of such as


T[length] asStatic(T, size_t length)(return scope T[length] 
arr)

{
return arr;
}

but all complain about the same thing

Error: parameter arr is 'return' but function does not return any 
indirections


It seems like compiler incorrectly infers that `arr` must be 
`return` despite it doesn't have any indirections (because it's a 
static array).


Walter?


Re: Android Status

2017-01-02 Thread Ignacious via Digitalmars-d-learn

On Monday, 2 January 2017 at 03:08:10 UTC, Joakim wrote:

On Sunday, 1 January 2017 at 09:34:24 UTC, Ignacious wrote:


Can you try

sudo apt-get install libconfig9

I don't know if that will install something different, but 
it's the command I see others using online.  Otherwise, check 
if the libconfig++9 package you installed included 
libconfig.so.9, which is what ldc is linked against.  If not, 
install the package that provides that library.  The wiki 
mentions installing libconfig-dev, you could always just 
install that if nothing else works.





That is what I used to get it on there in the first place... 
but the ldc compiler still could not find it.


The problem seems to be where ldc2 is looking for 
libconfig.so.9 rather than it being installed or not.


How do I either know where it is looking for where to put it?


You said you installed libconfig++9, which an apt search shows 
me is a different package than libconfig9, that includes a 
library named differently.  As I said, are you sure that 
particular libconfig.so.9 library is installed?


If it is, manually adding its path to LD_LIBRARY_PATH is the 
way to make sure it's found.


Ok, I didn't realize they were different packages.

I now get the error

./bin/ldmd2: error while loading shared libraries: 
libncursesw.so.6: cannot open shared object file: No such file or 
directory


and trying to install libncursesw is missing. I tried installing 
libncurses5 and it worked, but, of course, not version 6 or 
whatever. tried various things... nothing works.


./bin/ldc2: error while loading shared libraries: 
libncursesw.so.6: cannot open shared object file: No such file or 
directory


I downloaded the sources. I had to install gcc, make, then I did 
./configure --enable-widec 
(http://arstechnica.com/civis/viewtopic.php?f=20&t=1161942), then 
ran make.. I end up getting the errors


make[1]: Leaving directory `/mnt/b/c/test'
cd misc && make DESTDIR="" all
make[1]: Entering directory `/mnt/b/c/misc'
WHICH_XTERM=xterm-new \
ticdir=/usr/share/terminfo \
/bin/sh ./gen_edit.sh >run_tic.sed
echo '** adjusting tabset paths'
** adjusting tabset paths
sed -f run_tic.sed ../misc/terminfo.src >terminfo.tmp
make[1]: Leaving directory `/mnt/b/c/misc'
cd c++ && make DESTDIR="" all
make[1]: Entering directory `/mnt/b/c/c++'
cp ./etip.h.in etip.h
sh ./edit_cfg.sh ../include/ncurses_cfg.h etip.h
substituting autoconf'd values from ../include/ncurses_cfg.h into 
etip.h

... CPP_HAS_PARAM_INIT 0
... CPP_HAS_STATIC_CAST 0
... ETIP_NEEDS_MATH_EXCEPTION 0
... ETIP_NEEDS_MATH_H 0
... HAVE_BUILTIN_H 0
... HAVE_GPP_BUILTIN_H 0
... HAVE_GXX_BUILTIN_H 0
... HAVE_IOSTREAM 0
... HAVE_TYPEINFO 0
... HAVE_VALUES_H 0
... IOSTREAM_NAMESPACE 0
cd ../objects;   -I../c++ -I../include -I. -DHAVE_CONFIG_H  
-D_GNU_SOURCE -DNDEBUG -I. -I../include  -c ../c++/cursesf.cc

/bin/sh: 1: -I../c++: not found
make[1]: *** [../objects/cursesf.o] Error 127
make[1]: Leaving directory `/mnt/b/c/c++'
make: *** [all] Error 2

So, now I do not know what to do next.


Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libncurses6

(This is why I hate working linux, so much obfuscation... so many 
potential points of failure)


Also, once I go through all this trouble, I have to do it again 
for the arm verson(using x86-64 ldc)? Can I install on the same 
system or will the libraries conflict and I'll have to go through 
all this mess again?