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!stri

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

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

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.

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) !

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 fo

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 st

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 follow

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 > >> d

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,

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. ;-)

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,

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 > >thou

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

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 chos

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 afr

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

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 eas

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

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-5E103

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 thou

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.s

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.s

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

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 <...> /tm

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 st

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 every

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 t

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 d

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

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

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.06