Re: Parameterized enum does not work

2015-01-08 Thread Daniel Kozak via Digitalmars-d-learn

On Friday, 9 January 2015 at 07:50:53 UTC, Daniel Kozak wrote:

On Friday, 9 January 2015 at 06:17:53 UTC, Andre wrote:

Hi,

Should following coding work?

string lpad(ubyte length, long n)
{
import std.string: rightJustify;
import std.conv: to;
return rightJustify(to!string(n), length, '0');
}

enum lpad14(long n) = lpad(14, n);

void main()
{
lpad14(123);
}

There is following error from dmd:

source\app.d(12): Error: template app.lpad14 cannot deduce 
function from argumen

t types !()(int), candidates are:
source\app.d(8):app.lpad14(long n)

Kind regards
André


What are you trying to do?


OK I probably see it now :):

import std.stdio;

string lpad(ubyte length, long n)
{
import std.string: rightJustify;
import std.conv: to;
return rightJustify(to!string(n), length, '0');
}

enum lpad14(long n) = lpad(14, n);

void main()
{
writeln(lpad14!(123));
}


Re: Fastest Way of Accessing Entries in an AA

2015-01-08 Thread Foo via Digitalmars-d-learn
On Friday, 9 January 2015 at 06:18:53 UTC, Jonathan M Davis via 
Digitalmars-d-learn wrote:
On Friday, January 09, 2015 00:20:07 Foo via 
Digitalmars-d-learn wrote:

On Thursday, 8 January 2015 at 23:06:39 UTC, Nordlöw wrote:
> On Thursday, 8 January 2015 at 16:11:07 UTC, ketmar via
> Digitalmars-d-learn wrote:
>> how can it? compiler doesn't know what the code is supposed 
>> to

>> do. if
>> compilers will know such things someday, we can stop writing
>> programs
>> altogether, as compilers will be able to write any program 
>> for

>> us. ;-)
>
> Correction:
>
> I thought it would be nice if the compiler explained to me 
> that

>
> key in aa ? aa[key]
>
> is a sub-optimal performance-wise.

You know, that you kan reuse the result of the in operator by 
AAs?


example:

auto ptr = key in aa;
ptr ? *ptr : ValueType.init


This idiom is quite common:

if(auto ptrToValue = key in aa)
{
}

though I'm not sure that that quite fits in with what Nordlow 
seems to be
trying to do with init. aa.get probably does a better job of 
that, though
looking at the implementation for get, it's basically doing 
what you're

suggesting:

auto p = key in aa;
return p ? *p : defaultValue;

though that has the downside of using a lazy parameter for the 
default
value, which is convenient but doesn't do great things for 
performance.


- Jonathan M Davis

I just wasn't sure that he knows about it.


Re: Parameterized enum does not work

2015-01-08 Thread Daniel Kozak via Digitalmars-d-learn

On Friday, 9 January 2015 at 06:17:53 UTC, Andre wrote:

Hi,

Should following coding work?

string lpad(ubyte length, long n)
{
import std.string: rightJustify;
import std.conv: to;
return rightJustify(to!string(n), length, '0');
}

enum lpad14(long n) = lpad(14, n);

void main()
{
lpad14(123);
}

There is following error from dmd:

source\app.d(12): Error: template app.lpad14 cannot deduce 
function from argumen

t types !()(int), candidates are:
source\app.d(8):app.lpad14(long n)

Kind regards
André


What are you trying to do?



Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-08 Thread ketmar via Digitalmars-d-learn
On Fri, 09 Jan 2015 07:10:14 +
FrankLike via Digitalmars-d-learn 
wrote:

> On Thursday, 8 January 2015 at 15:15:59 UTC, Robert burner 
> Schadek wrote:
> >
> > use canFind like such:
> > bool a = canFind(strs,s) >= 1;
> >
> > let the compiler figger out what the types of the parameter are.
> 
> canFind is work for such as :
>   bool x = canFind(["exe","lib","a","dll"],"a" );
> but can't work for canFind(["exe","lib","a","dll"],"hello.lib");
> 
> So  I very want to let the function 'indexOfAny' do the same work.
> 
> Thank you.
> 
> Frank
be creative! ;-)

  import std.algorithm, std.stdio;

  void main () {
string fname = "hello.exe";
import std.path : extension;
if (findAmong([fname.extension], [".exe", ".lib", ".a", ".dll"]).length) {
  writeln("got it!");
} else {
  writeln("alas...");
}
  }

note the dots in extension list.

yet you can do it even easier:

  import std.algorithm, std.stdio;

  void main () {
string fname = "hello.exe";
import std.path : extension;
if ([".exe", ".lib", ".a", ".dll"].canFind(fname.extension)) {
  writeln("got it!");
} else {
  writeln("alas...");
}
  }

as you obviously interested in extension here -- check only that
part! ;-)


signature.asc
Description: PGP signature


checking if template arg is literal, possible ER for compiler change

2015-01-08 Thread ketmar via Digitalmars-d-learn
Hello.

disclaimer: please, ignore compiler inlining abilities while you are
reading this post. i'll give some reasoning later.


let's imagine that we have such function:

  void putPixel (int x, int y, uint color) {
if ((color&0xff) == 0) {
  // replace pixel
} else if ((color&0xff) != 0xff) {
  // do color blending
} // and do nothing for transparent pixels
  }

and it's often calling like this: `putPixel(x, y, Color.White);` (or
another color constant). `Color.White` is not transparent.

but why we should do all the checks if we know the argument value at
compile time? it would be wonderful if we'll be able to do something
like this:

  void putPixel() (int x, int y, uint color) {
static if (isLiteralArg!color) {
  static if ((literalArgValue!color&0xff) == 0) {
// replace pixel
  } else static if ((literalArgValue!color&0xff) != 0xff) {
// do color blending with code
// optimised for the given color
  } // and do nothing for transparent pixels
} else {
  if ((color&0xff) == 0) {
// replace pixel
  } else if ((color&0xff) != 0xff) {
// do color blending
  } // and do nothing for transparent pixels
}
  }

i named new traits `isLiteralArg` and `literalArgValue` here. yes, we
see code duplication here, but this is another story. what is important
is that we can generate specialised versions of `putPixel` based on
argument value which is known in compile time.

sure, for easy cases like this we can rely on compiler inlining
abilities. yet inlining may fail without warning (having warning about
failing inlines is nice, but this is completely different story).

and what is much more important is that we can specialise `putPixel`
with known color value. we can, for example, generate different code
for different opacities and so on.

we can introduce range checking for `x` and `y` and omit that if we
know their values at compile time.

the thing is that we have "controlled inlining" here without resorting
to something like this:

  void putPixel(alias x, alias y, alias color) ()
  if (isIntegral!(typeof(x)) && isIntegral!(typeof(y)) &&
  isIntegral!(typeof(color))
  {
static if (!is(color)) {
  // color is literal
} else {
  // color is not known in compile time
}
  }

besides looking ugly with all those `isIntegral!` checks, which makes
signature unreadable, we now forced to call it like
`putPixel!(x, y, c);` instead of `putPixel(x, y, c);`.
ah, and compiler error messages are not really readable in this case.


what i want to say here is that having a way to check if *function*
args for templated function are literals (and get their values) can be
useful for various patterns of compile-time code generation and
parameterization without resorting to ugly signatures and unnatural
"bang calling".

this can break template instantiation though, as we cannot assume that
template with identical argument types will instantiate to identical
functions, but i don't think that this is of great importance: compiler
can do AST comparisons on various instances later.

this will change some instantiated function signatures too, as they now
will depend of literal arguments. so it will be wise to do this only
for templates that explicitly used `isLiteralArg` and `literalArgValue`
traits.

this seems to be a not-so-small change of compiler internals, so i want
to know if i'm completely insane here or there are more people that see
a sane practical value in such feature.


signature.asc
Description: PGP signature


Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-08 Thread FrankLike via Digitalmars-d-learn
On Thursday, 8 January 2015 at 15:15:59 UTC, Robert burner 
Schadek wrote:


use canFind like such:
bool a = canFind(strs,s) >= 1;

let the compiler figger out what the types of the parameter are.


canFind is work for such as :
 bool x = canFind(["exe","lib","a","dll"],"a" );
but can't work for canFind(["exe","lib","a","dll"],"hello.lib");

So  I very want to let the function 'indexOfAny' do the same work.

Thank you.

Frank


Re: Fastest Way of Accessing Entries in an AA

2015-01-08 Thread ketmar via Digitalmars-d-learn
On Thu, 08 Jan 2015 23:06:38 +
"Nordlöw" via Digitalmars-d-learn 
wrote:

> On Thursday, 8 January 2015 at 16:11:07 UTC, ketmar via 
> Digitalmars-d-learn wrote:
> > how can it? compiler doesn't know what the code is supposed to 
> > do. if
> > compilers will know such things someday, we can stop writing 
> > programs
> > altogether, as compilers will be able to write any program for 
> > us. ;-)
> 
> Correction:
> 
> I thought it would be nice if the compiler explained to me that
> 
>  key in aa ? aa[key]
> 
> is a sub-optimal performance-wise.
although it's right in most cases, it's still implying that compiler is
able to understand the code behind `in` and `[key]`, as they aren't
built into the compiler, but rather coded in druntime. producing
warning on such code can create wrong impression about compiler code
analysing abilities.

this time i think that it's a work for a linter, 'cause there is
nothing wrong with the code, it's just a questionable style. so let
linter question it. ;-)


signature.asc
Description: PGP signature


Parameterized enum does not work

2015-01-08 Thread Andre via Digitalmars-d-learn

Hi,

Should following coding work?

string lpad(ubyte length, long n)
{
import std.string: rightJustify;
import std.conv: to;
return rightJustify(to!string(n), length, '0');
}

enum lpad14(long n) = lpad(14, n);

void main()
{
lpad14(123);
}

There is following error from dmd:

source\app.d(12): Error: template app.lpad14 cannot deduce 
function from argumen

t types !()(int), candidates are:
source\app.d(8):app.lpad14(long n)

Kind regards
André


Re: Fastest Way of Accessing Entries in an AA

2015-01-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 09, 2015 00:20:07 Foo via Digitalmars-d-learn wrote:
> On Thursday, 8 January 2015 at 23:06:39 UTC, Nordlöw wrote:
> > On Thursday, 8 January 2015 at 16:11:07 UTC, ketmar via
> > Digitalmars-d-learn wrote:
> >> how can it? compiler doesn't know what the code is supposed to
> >> do. if
> >> compilers will know such things someday, we can stop writing
> >> programs
> >> altogether, as compilers will be able to write any program for
> >> us. ;-)
> >
> > Correction:
> >
> > I thought it would be nice if the compiler explained to me that
> >
> > key in aa ? aa[key]
> >
> > is a sub-optimal performance-wise.
>
> You know, that you kan reuse the result of the in operator by AAs?
>
> example:
>
> auto ptr = key in aa;
> ptr ? *ptr : ValueType.init

This idiom is quite common:

if(auto ptrToValue = key in aa)
{
}

though I'm not sure that that quite fits in with what Nordlow seems to be
trying to do with init. aa.get probably does a better job of that, though
looking at the implementation for get, it's basically doing what you're
suggesting:

auto p = key in aa;
return p ? *p : defaultValue;

though that has the downside of using a lazy parameter for the default
value, which is convenient but doesn't do great things for performance.

- Jonathan M Davis




Re: Fastest Way of Accessing Entries in an AA

2015-01-08 Thread Foo via Digitalmars-d-learn

On Thursday, 8 January 2015 at 23:06:39 UTC, Nordlöw wrote:
On Thursday, 8 January 2015 at 16:11:07 UTC, ketmar via 
Digitalmars-d-learn wrote:
how can it? compiler doesn't know what the code is supposed to 
do. if
compilers will know such things someday, we can stop writing 
programs
altogether, as compilers will be able to write any program for 
us. ;-)


Correction:

I thought it would be nice if the compiler explained to me that

key in aa ? aa[key]

is a sub-optimal performance-wise.


You know, that you kan reuse the result of the in operator by AAs?

example:

auto ptr = key in aa;
ptr ? *ptr : ValueType.init


Re: Fastest Way of Accessing Entries in an AA

2015-01-08 Thread Nordlöw
On Thursday, 8 January 2015 at 16:11:07 UTC, ketmar via 
Digitalmars-d-learn wrote:
how can it? compiler doesn't know what the code is supposed to 
do. if
compilers will know such things someday, we can stop writing 
programs
altogether, as compilers will be able to write any program for 
us. ;-)


Correction:

I thought it would be nice if the compiler explained to me that

key in aa ? aa[key]

is a sub-optimal performance-wise.


Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-08 Thread Joseph Rushton Wakeling via Digitalmars-d-learn

On 07/01/15 16:02, Laeeth Isharc via Digitalmars-d-learn wrote:

class node
{
 string name;
 node ref;
}


Small recommendation (apart from the reserved word issue which you fixed): it's 
generally considered good D style to give structs and classes names that start 
with capital letters, JustLikeThis.  So, I suggest Node rather than node.


Very minor point, and of course, your code is yours to style as you wish, but it 
can be helpful to meet the "standard" style conventions in order to make it as 
easy as possible for everyone else to understand.


See also: http://dlang.org/dstyle.html



Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-08 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 08, 2015 at 07:13:28PM +, Paulo Pinto via Digitalmars-d-learn 
wrote:
> On Thursday, 8 January 2015 at 17:42:23 UTC, H. S. Teoh via
> Digitalmars-d-learn wrote:
[...]
> >Vim supports syntax highlighting.
> >
> >But I don't use it either -- I find it distracts from clarity of
> >thought. I use plain vanilla vim in a text-only terminal.
[...]
> I don't get this, then again I am using syntax highlighting editors
> since MS-DOS IDEs supported it.
[...]

It's just a personal preference. I find that overuse of colors produces
a kaleidoscopic rainbow pattern on the screen which, while pretty,
distracts from the essence of the code itself, which is what I'm
focusing on. It's like a webpage with every other word italicized and/or
bolded -- after a while, your brain just tunes it out and it becomes
just meaningless (and distracting) noise. I much rather learn to parse
the text (resp. code) accurately by eye and let it speak for itself.


T

-- 
Those who've learned LaTeX swear by it. Those who are learning LaTeX swear at 
it. -- Pete Bleackley


Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-08 Thread Paulo Pinto via Digitalmars-d-learn
On Thursday, 8 January 2015 at 17:42:23 UTC, H. S. Teoh via 
Digitalmars-d-learn wrote:
On Thu, Jan 08, 2015 at 11:29:29AM +, Laeeth Isharc via 
Digitalmars-d-learn wrote:


>this conversation is so funny: well what's wrong with this . 
>It's a

>keyword...
>Aa Ha ha ha ha , rol.
>Seriously, is it so complicated to use a D editor ? I mean 
>with

>syntax color...

Man afraid to ask stoopid questions stays stoopid.  And 
compiler error

message far from informative.
Not everyone is very visually oriented, and sometimes vi is 
quicker.


Vim supports syntax highlighting.

But I don't use it either -- I find it distracts from clarity of
thought. I use plain vanilla vim in a text-only terminal.


T


I don't get this, then again I am using syntax highlighting 
editors since MS-DOS IDEs supported it.


--
Paulo



Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

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

On 01/08/2015 09:40 AM, H. S. Teoh via Digitalmars-d-learn wrote:

> Vim supports syntax highlighting.
>
> But I don't use it either -- I find it distracts from clarity of
> thought. I use plain vanilla vim in a text-only terminal.

I am halfway there: I use syntax highlighting in Emacs but I chose to 
make keywords and variables the same color.


Ali



Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-08 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 08, 2015 at 11:29:29AM +, Laeeth Isharc via Digitalmars-d-learn 
wrote:
> 
> >this conversation is so funny: well what's wrong with this . It's a
> >keyword...
> >Aa Ha ha ha ha , rol.
> >Seriously, is it so complicated to use a D editor ? I mean with
> >syntax color...
> 
> Man afraid to ask stoopid questions stays stoopid.  And compiler error
> message far from informative.
> Not everyone is very visually oriented, and sometimes vi is quicker.

Vim supports syntax highlighting.

But I don't use it either -- I find it distracts from clarity of
thought. I use plain vanilla vim in a text-only terminal.


T

-- 
Those who've learned LaTeX swear by it. Those who are learning LaTeX swear at 
it. -- Pete Bleackley


Re: Fastest Way of Accessing Entries in an AA

2015-01-08 Thread ketmar via Digitalmars-d-learn
On Thu, 08 Jan 2015 15:59:10 +
"Nordlöw" via Digitalmars-d-learn 
wrote:

> On Thursday, 8 January 2015 at 15:49:46 UTC, Dragos Carp wrote:
> > On Thursday, 8 January 2015 at 15:45:27 UTC, Nordlöw wrote:
> >> Is
> >>
> >>key in aa ? aa[key] : ValueType.init;
> >>
> >> the most efficient way to maybe return a value from an 
> >> associative array aa?
> >
> > aa.get(key, ValueType.init)
> 
> That was too easy ;)
> 
> It would be nice if the compiler could detect usage of aa.get() 
> automatically and issue either a diagnostics or transform it in 
> an optimization pass.
how can it? compiler doesn't know what the code is supposed to do. if
compilers will know such things someday, we can stop writing programs
altogether, as compilers will be able to write any program for us. ;-)


signature.asc
Description: PGP signature


Re: Fastest Way of Accessing Entries in an AA

2015-01-08 Thread Nordlöw

On Thursday, 8 January 2015 at 15:49:46 UTC, Dragos Carp wrote:

On Thursday, 8 January 2015 at 15:45:27 UTC, Nordlöw wrote:

Is

   key in aa ? aa[key] : ValueType.init;

the most efficient way to maybe return a value from an 
associative array aa?


aa.get(key, ValueType.init)


That was too easy ;)

It would be nice if the compiler could detect usage of aa.get() 
automatically and issue either a diagnostics or transform it in 
an optimization pass.


Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-08 Thread Steven Schveighoffer via Digitalmars-d-learn

On 1/8/15 12:15 AM, Meta wrote:

On Wednesday, 7 January 2015 at 23:27:19 UTC, anonymous wrote:

Don't do this without `dup`ing. Quoting the documentation:


Oh, whoops. I thought those special variadic args were always allocated
on the heap.


Nope,

Which makes it annoying, what if the argument IS passed on the heap?

Fortunately, there is a solution (one I use in dcollections):

foo(T[] x...)
foo(T[] x)

Can be overloaded. If you ever pass in parameters one at a time, the 
first is called, and x is guaranteed to be on the stack.


The second is called with an actual array only, you are able to not 
'dup', and just warn people that x will NOT be dup'd in that case.


-Steve


Re: Fastest Way of Accessing Entries in an AA

2015-01-08 Thread Dragos Carp via Digitalmars-d-learn

On Thursday, 8 January 2015 at 15:45:27 UTC, Nordlöw wrote:

Is

key in aa ? aa[key] : ValueType.init;

the most efficient way to maybe return a value from an 
associative array aa?


aa.get(key, ValueType.init)


Re: What does dmd 2.066 want from me?

2015-01-08 Thread Steven Schveighoffer via Digitalmars-d-learn

On 1/7/15 3:10 PM, Artem Tarasov wrote:

I'm trying to compile my software with the latest compiler, and it spits
out the following error:

$ make
<...>
rdmd --force --build-only -IBioD -g -L-Lhtslib -L-l:libhts.a
-L-l:libphobos2.a -ofbuild/sambamba.o main.d
<...>
/tmp/.rdmd-1000/rdmd-main.d-5E103AD0DCA0998F00B4F9BA5B181EDE/objs/sambamba.o.o:(.data._D80TypeInfo_S3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamRead6__initZ+0x30):
undefined reference to
`_D3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamRead9__xtoHashFNbNeKxS3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamReadZm'

/tmp/.rdmd-1000/rdmd-main.d-5E103AD0DCA0998F00B4F9BA5B181EDE/objs/sambamba.o.o:(.data._D80TypeInfo_S3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamRead6__initZ+0x38):
undefined reference to
`_D3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamRead11__xopEqualsFKxS3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamReadKxS3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamReadZb'


What the heck do these lines mean? Presumably they come from the recent
change in hash implementation, but I don't use this struct in any
dictionary whatsoever! It doesn't have opCmp either and perfectly worked
until now.


The latest changes are compile-time requirements, not link-time. I doubt 
they have to do with your problem.


Check for stale objects and libraries.

-Steve


Fastest Way of Accessing Entries in an AA

2015-01-08 Thread Nordlöw

Is

key in aa ? aa[key] : ValueType.init;

the most efficient way to maybe return a value from an 
associative array aa?


Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-08 Thread Robert burner Schadek via Digitalmars-d-learn


use canFind like such:
bool a = canFind(strs,s) >= 1;

let the compiler figger out what the types of the parameter are.


Re: Define methods using templates

2015-01-08 Thread Claude via Digitalmars-d-learn
I just saw this post, which is essentially the same question as 
Basile Burg's. I hope that a college (in France?) is teaching D 
and that this is a homework assignment. Cool stuff! :)


Maybe using templates to create properties is a bit overkill in 
this example. But I could not solve what I thought would be a 
very simple and straightforward "template use-case" (initially 
I'm an embedded RT system C/asm developer).


I'm doing this for a personal project of a 3D engine. As I know 
little about C++/Java or other OO language, I thought I would do 
it directly in D, which seems very promising to me (but 
unfortunately not taught in France as far as I know).


Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-08 Thread FrankLike via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 17:08:55 UTC, H. S. Teoh via 
Digitalmars-d-learn wrote:

Try this:

http://dlang.org/phobos-prerelease/std_algorithm#.findAmong


T


Thank you,it can work. but it's not what I want.

---test.d--
import  std.stdio, std.algorithm,std.string;

auto ext =["exe","lib","a","dll"];
auto strs = "hello.dll";

void main()
{
auto b = findAmong(ext,strs);
writeln("b is ",b);
}
-result-
b is ["dll"]


I think if  'indexOfAny' function of string.d do the work ,it 
should be ok.


such as :

 auto b = "hello.dll".indexOfAny(["exe","lib","a","dll"]);
writeln("b is ",b);

The result should be 'true',if it can work.

Can you suggest 'phobos' to update 'indexOfAny' fuction?

Thank you.
Frank


Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-08 Thread FrankLike via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 17:08:55 UTC, H. S. Teoh via 
Digitalmars-d-learn wrote:

Try this:

http://dlang.org/phobos-prerelease/std_algorithm#.findAmong


T


You mean ? The result is not that I want to get!

---test.d--
import  std.stdio, std.algorithm,std.string;

auto ext =["exe","lib","a","dll"];
auto strs = "hello.exe";

void main()
{
auto b = findAmong(ext,strs);
writeln("b is ",b);
}
-result-
b is ["exe","lib","a","dll"]

note:
1. I only want to find the given string 'hello.exe' whether to 
include any a string in the ["exe","lib","a","dll"].
2. I think the 'indexOfAny' function of string.d do the same work 
with 'indexOf',This is not as it should be.


Frank


Re: How to prevent sensitive information is displayed when the extension 'exe' is modified to 'txt' on windows?

2015-01-08 Thread FrankLike via Digitalmars-d-learn

On Thursday, 8 January 2015 at 10:11:38 UTC, Danny wrote:

Hi,

sigh, so I have to annoy you with the truth...

On Tuesday, 6 January 2015 at 17:15:28 UTC, FrankLike wrote:
How to prevent sensitive information is displayed when the 
extension 'exe' is modified to 'txt' on windows?


By not putting it in in the first place. Everything else is no 
good in the end. Encryption, xoring, everything is almost 
useless for that purpose.


If you build a exe ,such as which can get Data from 
DataBase,when you modify the exe's  extension to 'txt',
and you open it by notepad.exe (on windows),you will find the 
info,it's important for me,so how to stop  the info to display

 ?


Do you mean find the password? (I don't see that field in your 
example)


Remove the password field and let the operating system care of 
auth forwarding to the database server. Then create all the 
users on your database and make sure to set their permissions 
right. That way, your computer and the database server will 
negotiate whether they let the user in and it's their problem. 
I always do it like that. Also, that way, you already have 
existing permission management tools (in the dbms).


If you don't want to grant them permission on the table, don't. 
Create a view with the harmless info and grant them permission 
to that. Likewise, if you want to completely abstract it away, 
create stored procedures in the database as the interface for 
your app and grant them only permission to execute them.



Trusted_Connection=Yes\


Well, now I don't see what the problem you are trying to solve 
is. You are doing as outlined above already.


So what is the problem you are trying to solve?


'Trusted_Connection=Yes' is for local DB(127.0.0.1) ,but for 
network ,must have the username and password.

I have known how to do,but thank you.


Re: What does dmd 2.066 want from me?

2015-01-08 Thread John Colvin via Digitalmars-d-learn

On Wednesday, 7 January 2015 at 20:10:35 UTC, Artem Tarasov wrote:
I'm trying to compile my software with the latest compiler, and 
it spits out the following error:


$ make
<...>
rdmd --force --build-only -IBioD -g -L-Lhtslib -L-l:libhts.a 
-L-l:libphobos2.a -ofbuild/sambamba.o main.d

<...>
/tmp/.rdmd-1000/rdmd-main.d-5E103AD0DCA0998F00B4F9BA5B181EDE/objs/sambamba.o.o:(.data._D80TypeInfo_S3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamRead6__initZ+0x30): 
undefined reference to 
`_D3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamRead9__xtoHashFNbNeKxS3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamReadZm'
/tmp/.rdmd-1000/rdmd-main.d-5E103AD0DCA0998F00B4F9BA5B181EDE/objs/sambamba.o.o:(.data._D80TypeInfo_S3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamRead6__initZ+0x38): 
undefined reference to 
`_D3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamRead11__xopEqualsFKxS3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamReadKxS3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamReadZb'


What the heck do these lines mean? Presumably they come from 
the recent change in hash implementation, but I don't use this 
struct in any dictionary whatsoever! It doesn't have opCmp 
either and perfectly worked until now.


Are you totally sure that you don't have any old .o or .a files 
lying around? Remember that D offers no binary compatibility 
across compiler releases.


Also, are you absolutely certain that 1) the correct dmd.conf is 
being used and 2) the correct version of druntime/phobos is 
specified in dmd.conf


Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-08 Thread Mengu via Digitalmars-d-learn

On Thursday, 8 January 2015 at 11:29:30 UTC, Laeeth Isharc wrote:


this conversation is so funny: well what's wrong with this . 
It's a keyword...

Aa Ha ha ha ha , rol.
Seriously, is it so complicated to use a D editor ? I mean 
with syntax color...


Man afraid to ask stoopid questions stays stoopid.  And 
compiler error message far from informative.
Not everyone is very visually oriented, and sometimes vi is 
quicker.


don't worry about it. use whatever you're comfortable with.


Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-08 Thread Laeeth Isharc via Digitalmars-d-learn


this conversation is so funny: well what's wrong with this . 
It's a keyword...

Aa Ha ha ha ha , rol.
Seriously, is it so complicated to use a D editor ? I mean with 
syntax color...


Man afraid to ask stoopid questions stays stoopid.  And compiler 
error message far from informative.
Not everyone is very visually oriented, and sometimes vi is 
quicker.


Re: How to prevent sensitive information is displayed when the extension 'exe' is modified to 'txt' on windows?

2015-01-08 Thread Danny via Digitalmars-d-learn

Hi,

sigh, so I have to annoy you with the truth...

On Tuesday, 6 January 2015 at 17:15:28 UTC, FrankLike wrote:
How to prevent sensitive information is displayed when the 
extension 'exe' is modified to 'txt' on windows?


By not putting it in in the first place. Everything else is no 
good in the end. Encryption, xoring, everything is almost useless 
for that purpose.


If you build a exe ,such as which can get Data from 
DataBase,when you modify the exe's  extension to 'txt',
and you open it by notepad.exe (on windows),you will find the 
info,it's important for me,so how to stop  the info to display  
?


Do you mean find the password? (I don't see that field in your 
example)


Remove the password field and let the operating system care of 
auth forwarding to the database server. Then create all the users 
on your database and make sure to set their permissions right. 
That way, your computer and the database server will negotiate 
whether they let the user in and it's their problem. I always do 
it like that. Also, that way, you already have existing 
permission management tools (in the dbms).


If you don't want to grant them permission on the table, don't. 
Create a view with the harmless info and grant them permission to 
that. Likewise, if you want to completely abstract it away, 
create stored procedures in the database as the interface for 
your app and grant them only permission to execute them.



Trusted_Connection=Yes\


Well, now I don't see what the problem you are trying to solve 
is. You are doing as outlined above already.


So what is the problem you are trying to solve?


DDOX question

2015-01-08 Thread Vadim Lopatin via Digitalmars-d-learn

Hello!

I'm trying to generate documentation for a library.
I like result of DDOX generation - nice navigation by modules and 
classes.
But I cannot figure out how to generate custom pages (e.g. from 
.dd .d Ddoc), and how to add links to custom pages to all 
generated pages, e.g. like on Vibe.d documentation site.


Could someone point on example or docs wich can help me?

Best regards,
Vadim


Re: Any chance of a linux dtoh?

2015-01-08 Thread Joakim via Digitalmars-d-learn

On Tuesday, 6 January 2015 at 16:02:24 UTC, Laeeth Isharc wrote:
I downgraded dmd and now have a different problem with tango at 
link stage, which is progress of a sort.  (I updated the 
ticket).


Do you have to compile it yourself?  Arch comes with dstep in 
their package repository, put there by Dicebot, I just used that. 
 I don't know if any other distros have it packaged though.


Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-08 Thread Tobias Pankrath via Digitalmars-d-learn




what's wrong with the code above ?  i get an error no 
identifier for declarator node.  (I have not used classes 
much, since structs often seem to be enough for what I need 
to do mostly).


ref is a reserved keyword.

--
Paulo


this conversation is so funny: well what's wrong with this . 
It's a keyword...

Aa Ha ha ha ha , rol.
Seriously, is it so complicated to use a D editor ? I mean with 
syntax color...


No need to make fun of anyone.


Re: What does dmd 2.066 want from me?

2015-01-08 Thread Artem Tarasov via Digitalmars-d-learn
On Thursday, 8 January 2015 at 01:22:54 UTC, Rikki Cattermole 
wrote:

Have you got opEqual's defined?
Its wanting that and toHash I think.


Yes, I have opEquals defined. I've just tried to add dummy toHash 
(returning a constant), but it doesn't help :(


OK, it seems I'll have to stick with 2.065 and LDC 0.15. These 
new bugs in every new version of compiler drive me nuts.

Thanks for trying to help, anyway.