Re: using the full range of ubyte with iota

2015-01-24 Thread ketmar via Digitalmars-d-learn
juicy question! signature.asc Description: PGP signature

Re: using the full range of ubyte with iota

2015-01-24 Thread ketmar via Digitalmars-d-learn
On Sat, 24 Jan 2015 20:49:01 +, Dominikus Dittes Scherkl wrote: Maybe I'm just too stupid, but I cannot manage to call a simple function with all 256 possible values of ubyte with iote: int foo(ubyte c); auto myRange = iota(0,256).map!foo; -- Error: function foo(ubyte c) is not

Re: byKeyValue does not exist for associative arrays

2015-01-24 Thread ketmar via Digitalmars-d-learn
On Sat, 24 Jan 2015 11:17:03 +, Bayan Rafeh wrote: Apparently byKeyValue does not exist for associative arrays, should it? void main() { int[string] a; a.byKeyValue(); //Error: byKeyValue doesn't exist. } If it shouldn't could someone remove it from the documentation?

Re: Overloaded function disappears on polymorphism

2015-01-24 Thread ketmar via Digitalmars-d-learn
On Sat, 24 Jan 2015 18:55:58 +, tcak wrote: main.d === class Car{ public void makeBeep( char c ){} public void makeBeep( string s ){} } class Tesla: Car{ override public void makeBeep( char c ){

Re: Run only unittest, skip main

2015-01-24 Thread ketmar via Digitalmars-d-learn
On Sat, 24 Jan 2015 10:52:26 -0800, H. S. Teoh via Digitalmars-d-learn wrote: On Sat, Jan 24, 2015 at 06:15:29PM +, tcak via Digitalmars-d-learn wrote: Is there any way to run only unittest codes, and ignore main function? DMD is running both of them when I use -unittest.

Re: Run only unittest, skip main

2015-01-24 Thread ketmar via Digitalmars-d-learn
On Sat, 24 Jan 2015 11:11:35 -0800, H. S. Teoh via Digitalmars-d-learn wrote: On Sat, Jan 24, 2015 at 07:02:35PM +, ketmar via Digitalmars-d-learn wrote: On Sat, 24 Jan 2015 10:52:26 -0800, H. S. Teoh via Digitalmars-d-learn wrote: On Sat, Jan 24, 2015 at 06:15:29PM +, tcak via

Re: crash on args.getopt

2015-01-24 Thread ketmar via Digitalmars-d-learn
On Sat, 24 Jan 2015 19:55:10 +, Suliman wrote: Look for Passing unrecognized options through in the documentation. Oh I see, but first part of question is still actual. And also what is benefits of using getopt instead of parsing args[] manually? well... you can skip writing custom

Re: Extracting Structure from HTML using Adam's dom.d

2015-01-22 Thread ketmar via Digitalmars-d-learn
On Thu, 22 Jan 2015 18:39:25 +, Adam D. Ruppe wrote: On Thursday, 22 January 2015 at 16:22:14 UTC, ketmar via Digitalmars-d-learn wrote: i miss it in Phobos. I'm sure it'd fail the phobos review process though. But since it is an independent file (or it + characterencodings.d for full

Re: Extracting Structure from HTML using Adam's dom.d

2015-01-22 Thread ketmar via Digitalmars-d-learn
On Thu, 22 Jan 2015 11:40:52 + Gary Willoughby via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 22 January 2015 at 11:23:49 UTC, Nordlöw wrote: What is the meaning of selectors such as `a[href]` used in doc.querySelectorAll(`a[href]`) ?

Re: How can I convert the following C to D.

2015-01-21 Thread ketmar via Digitalmars-d-learn
On Wed, 21 Jan 2015 23:50:59 + anon via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Wednesday, 21 January 2015 at 23:47:46 UTC, ketmar via Digitalmars-d-learn wrote: On Wed, 21 Jan 2015 23:44:49 + anon via Digitalmars-d-learn digitalmars-d-learn@puremagic.com

Re: How can I convert the following C to D.

2015-01-21 Thread ketmar via Digitalmars-d-learn
On Wed, 21 Jan 2015 23:44:49 + anon via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I have the following C code, how can I do the same in D. Info **info; info = new Info*[hl + 2]; int r; for(r = 0; r hl; r++) { info[r] = new Info[vl + 2]; } info[r] = NULL;

Re: Undefined reference error when array size is given

2015-01-20 Thread ketmar via Digitalmars-d-learn
On Tue, 20 Jan 2015 07:00:31 -0500 Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 1/19/15 4:49 PM, Steven Schveighoffer wrote: I figured it out, poll.d is missing from here: https://github.com/D-Programming-Language/druntime/blob/master/mak/SRCS

Re: rebind of const class variables

2015-01-20 Thread ketmar via Digitalmars-d-learn
On Tue, 20 Jan 2015 09:29:45 + qqiang via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I am writing a tree data structure, and I have the following code: ```D final class Node { private { int val_; Node parent_; Node left_; Node right_;

Re: rebind of const class variables

2015-01-20 Thread ketmar via Digitalmars-d-learn
On Tue, 20 Jan 2015 14:45:26 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: ketmar: Jonathan explains it very well. i can add the only thing: don't use `const` until you forced to. ;-) In D use immutable (or const) everywhere you can. Possibly mark

Re: Memory error when using a template in a class destructor

2015-01-20 Thread ketmar via Digitalmars-d-learn
On Tue, 20 Jan 2015 17:59:38 + JC via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: The following code throws a core.exception.InvalidMemoryOperationError@(0), anyone have an idea of what is causing it? --- import std.stdio; class Test { this() {

Re: Undefined reference error when array size is given

2015-01-19 Thread ketmar via Digitalmars-d-learn
On Mon, 19 Jan 2015 16:49:34 -0500 Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I figured it out, poll.d is missing from here: https://github.com/D-Programming-Language/druntime/blob/master/mak/SRCS So it's for some reason not purposely included.

Re: Undefined reference error when array size is given

2015-01-19 Thread ketmar via Digitalmars-d-learn
On Mon, 19 Jan 2015 17:05:22 -0500 Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: BTW, I've seen linker errors happen when you don't include a module, even if there's seemingly nothing to deal with in there. To the point where I just include all modules

Re: Number of Bits Needed to Represent a Zero-Offset Integer

2015-01-19 Thread ketmar via Digitalmars-d-learn
On Mon, 19 Jan 2015 12:04:38 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: As a follow-up to http://forum.dlang.org/thread/fdfwrdtjcawprvvko...@forum.dlang.org#post-qxudiyoygnvvbovhjfgt:40forum.dlang.org I'm looking for a function that figures out the number of

Re: Undefined reference error when array size is given

2015-01-19 Thread ketmar via Digitalmars-d-learn
On Mon, 19 Jan 2015 21:00:55 + tcak via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: What is the reason of this error exactly? core.sys.posix.poll.d module is not compiled into druntime. as it is in include path, compiler sees it and you can use `pollfd` struct. but as it's

Re: Undefined reference error when array size is given

2015-01-19 Thread ketmar via Digitalmars-d-learn
On Mon, 19 Jan 2015 21:00:55 + tcak via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: p.s. i love new binutils! % dmd z00.d z00.o: In function `D main': z00.d:(.text._Dmain+0xa): undefined reference to `core.sys.posix.poll.pollfd.init$' z00.d:(.text._Dmain+0x10): undefined

Re: Undefined reference error when array size is given

2015-01-19 Thread ketmar via Digitalmars-d-learn
On Mon, 19 Jan 2015 16:27:51 -0500 Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 1/19/15 4:16 PM, ketmar via Digitalmars-d-learn wrote: On Mon, 19 Jan 2015 21:00:55 + tcak via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: What

Re: A naive attempt at a refcounted class proxy

2015-01-15 Thread ketmar via Digitalmars-d-learn
On Thu, 15 Jan 2015 11:48:23 + Francesco Cattoglio via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Tuesday, 13 January 2015 at 18:52:25 UTC, ketmar via Digitalmars-d-learn wrote: On Tue, 13 Jan 2015 18:36:15 + aldanor via Digitalmars-d-learn digitalmars-d

Re: vibe.d Subdirectory?

2015-01-14 Thread ketmar via Digitalmars-d-learn
On Wed, 14 Jan 2015 12:37:33 + seany via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Wednesday, 14 January 2015 at 12:25:12 UTC, ketmar via Digitalmars-d-learn wrote: just forgot about that crappy scripting stuff and write your code in D! Actually I want to serve

Re: Pointers and offsets

2015-01-14 Thread ketmar via Digitalmars-d-learn
On Wed, 14 Jan 2015 01:16:52 + Bauss via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Is it possible to access a pointer by its offsets. Ex. write a 32bit integer to a byte pointer at ex. offset 4. yes, it is. it's same as in c/c++, except that you have to add one magic

Re: vibe.d Subdirectory?

2015-01-14 Thread ketmar via Digitalmars-d-learn
On Wed, 14 Jan 2015 11:40:25 + seany via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I am new to vibe.d and plying a bit with it. I notice, that in case of Apache, there is a root directory, often by default under /var/www or /srv/http (resp. ftp) if you are using

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 17:08:37 + Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I just finished reading aldanor's blog, so I know he is slightly allergic to naked functions and prefers classes ;) that's due to absense of modules in C/C++. and namespaces aren't

Re: A naive attempt at a refcounted class proxy

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 18:12:44 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Tuesday, 13 January 2015 at 16:43:09 UTC, ketmar via Digitalmars-d-learn wrote: On Tue, 13 Jan 2015 16:17:51 + aldanor via Digitalmars-d-learn digitalmars-d-learn

Re: A naive attempt at a refcounted class proxy

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 18:14:40 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: // thanks ketmar for answering another one of my stupid questions on n.g. :) ah, 'cmon, your questions aren't stupid at all! ;-) signature.asc Description: PGP signature

Re: reinterpret array

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 17:09:31 + Dominikus Dittes Scherkl via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: /// interpret an array of one type as an array of a different type. may i point you to this? import std.stdio; void main () { ubyte[] a = [42,0,0,0,

Re: A naive attempt at a refcounted class proxy

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 18:36:15 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Tuesday, 13 January 2015 at 18:19:42 UTC, ketmar via Digitalmars-d-learn wrote: and then you can go with structures in the first place, i think. remember that you have that k00l

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 18:35:15 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I guess two of my gripes with UFCS is (a) you really have to use public imports in the modules where the target types are defined so you bring all the symbols in whether you want it or

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Mon, 12 Jan 2015 22:07:13 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I see, thanks! :) I've started liking structs more and more recently as well and been pondering on how to convert a class-based code that looks like this (only the base class has any

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Mon, 12 Jan 2015 23:06:16 + jmh530 via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I had seen some stuff on alias thing, but I hadn't bothered to try to understand it until now. If I'm understanding the first example a href=http://dlang.org/class.html#AliasThis;here/a,

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Mon, 12 Jan 2015 22:07:13 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I see, thanks! :) I've started liking structs more and more recently as well and been pondering on how to convert a class-based code that looks like this (only the base class has any

Re: Endless static this call when used a thread in it

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 13:56:05 + tcak via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: it works normal now. But it doesn't explain above issue. What's the relation between a new thread and a module's initialiser? yes. signature.asc Description: PGP signature

Re: Map Lambda with Side-Effects

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 10:06:25 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Nordlöw: Has there been any discussions on making map require pure functions now that we have each? Perhaps I'd like Phobos map and filter to be annotated with pure and to

Re: Map Lambda with Side-Effects

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 11:26:01 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: ketmar: that will effectively rule out any usage of some global vars or other external state, turning it into either unnecessary mess, or unusable theoretical crap.

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 16:08:15 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Tuesday, 13 January 2015 at 08:33:57 UTC, ketmar via Digitalmars-d-learn wrote: On Mon, 12 Jan 2015 22:07:13 + aldanor via Digitalmars-d-learn digitalmars-d-learn

Re: A naive attempt at a refcounted class proxy

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 16:17:51 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: This discussion: http://forum.dlang.org/thread/bqtcdpsopxmnfbjyr...@forum.dlang.org -- led me wondering if it would be possible to create some crippled version of a class proxy that

Re: reinterpret array

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 20:52:13 + Dominikus Dittes Scherkl via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Tuesday, 13 January 2015 at 20:11:45 UTC, anonymous wrote: On Tuesday, 13 January 2015 at 20:00:57 UTC, Dominikus Dittes Scherkl wrote: So if I have a function

Re: reinterpret array

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 20:00:56 + Dominikus Dittes Scherkl via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: p.s. i don't intend to stop you from doing what you want to do, in no way. i was just trying to show you some things that you can accidentally missed. sorry if it looks

Re: Set null as function array parameter

2015-01-12 Thread ketmar via Digitalmars-d-learn
On Mon, 12 Jan 2015 16:32:30 + Oleg via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Monday, 12 January 2015 at 15:59:43 UTC, Adam D. Ruppe wrote: Why are you using ref? Take that off and you can pass any array, including null, with ease. Because dynamic arrays are

Re: D Beginner Trying Manual Memory Management

2015-01-12 Thread ketmar via Digitalmars-d-learn
On Mon, 12 Jan 2015 19:29:53 + jmh530 via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: the proper answer is too long to write (it will be more an article that a forum answer ;-), so i'll just give you some directions: import std.typecons; { auto b = scoped!B(); //

Re: D Beginner Trying Manual Memory Management

2015-01-12 Thread ketmar via Digitalmars-d-learn
On Mon, 12 Jan 2015 20:14:19 + jmh530 via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Thanks for the reply, I wasn't familiar with scoped. I was aware that structs are on the stack and classes are on the heap in D, but I didn't know it was possible to put a class on the

Re: D Beginner Trying Manual Memory Management

2015-01-12 Thread ketmar via Digitalmars-d-learn
On Mon, 12 Jan 2015 21:37:27 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Monday, 12 January 2015 at 20:30:45 UTC, ketmar via Digitalmars-d-learn wrote: it even has `RefCounted!`, but it doesn't play well with classes yet (AFAIR). I wonder if it's

Re: Set null as function array parameter

2015-01-12 Thread ketmar via Digitalmars-d-learn
On Mon, 12 Jan 2015 16:53:59 + Oleg via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Monday, 12 January 2015 at 16:44:42 UTC, ketmar via Digitalmars-d-learn wrote: nope, it means exactly what is written there. except that dynamic array is represented by struct

Re: Tuple/Typedef question

2015-01-11 Thread ketmar via Digitalmars-d-learn
On Sun, 11 Jan 2015 11:41:08 + Martin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Is there a way to get Tuple (and Typedef) from the std.typecons module to generate a new type that is unique on every instantiation? What I mean is: alias T1 = Tuple!(int, int); alias

Re: Tuple/Typedef question

2015-01-11 Thread ketmar via Digitalmars-d-learn
On Sun, 11 Jan 2015 12:00:19 + Martin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: as for `Typedef!` -- you can use it's third arg, cookie: import std.typecons; alias T1 = Tuple!(int, int); alias T2 = Tuple!(int, int); alias T1New = Typedef!(T1,

Re: Sqlite

2015-01-11 Thread ketmar via Digitalmars-d-learn
On Sun, 11 Jan 2015 20:00:03 + Paul via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Can someone please tell me what I'm doing wrong here, the sql INSERT statement fails for some reason. I don't fully understand the callback function yet (I borrowed this from a C tutorial

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

2015-01-09 Thread ketmar via Digitalmars-d-learn
On Fri, 09 Jan 2015 15:36:21 + FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 9 January 2015 at 14:03:21 UTC, ketmar via Digitalmars-d-learn wrote: On Fri, 09 Jan 2015 13:54:00 + Robert burner Schadek via Digitalmars-d-learn digitalmars-d

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

2015-01-09 Thread ketmar via Digitalmars-d-learn
On Fri, 09 Jan 2015 09:36:01 + FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Sorry,it's only a example .Thank you work hard,but it's not what I want. 'indexOfAny ' function should do this work. ”he is at home ,[home,office,”sea,plane], in

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

2015-01-09 Thread ketmar via Digitalmars-d-learn
On Fri, 09 Jan 2015 14:11:49 + Robert burner Schadek via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 9 January 2015 at 14:03:21 UTC, ketmar via Digitalmars-d-learn wrote: std.regex can use CTFE to compile regular expressions (yet it sometimes slower

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

2015-01-09 Thread ketmar via Digitalmars-d-learn
On Fri, 09 Jan 2015 13:54:00 + Robert burner Schadek via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 9 January 2015 at 13:25:17 UTC, ketmar via Digitalmars-d-learn wrote: if you *really* concerned with speed here, you'd better consider using regular

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

2015-01-09 Thread ketmar via Digitalmars-d-learn
On Fri, 09 Jan 2015 12:46:53 + FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: The code is the best,and it's better than indexOfAny in C#: import std.algorithm, std.stdio; void main () { auto places = [ home, office, sea,plane]; auto strWhere = He

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

2015-01-09 Thread ketmar via Digitalmars-d-learn
On Fri, 09 Jan 2015 13:06:09 + FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 9 January 2015 at 10:02:53 UTC, ketmar via Digitalmars-d-learn wrote: import std.algorithm, std.stdio; void main () { string s = he is at home

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 ((color0xff) == 0) { // replace pixel } else if ((color0xff) !=

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 digitalmars-d-learn@puremagic.com 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

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 digitalmars-d-learn@puremagic.com 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

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 digitalmars-d-learn@puremagic.com 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

Re: Any chance of a linux dtoh?

2015-01-06 Thread ketmar via Digitalmars-d-learn
On Tue, 06 Jan 2015 14:08:30 + Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I realize Walter has far better things to work on, but value of having a translation tool is considerable, since it opens up easy access to an enormous range of libraries. It is

Re: Error: function declaration without return type.

2015-01-06 Thread ketmar via Digitalmars-d-learn
On Tue, 06 Jan 2015 21:25:49 + Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Tuesday, 6 January 2015 at 21:19:38 UTC, bearophile wrote: Suliman: void foo() { writeln(test); writeln(mystring); } foo(); } I guess you have

Re: What exactly shared means?

2015-01-03 Thread ketmar via Digitalmars-d-learn
On Sat, 03 Jan 2015 12:14:54 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Saturday, 3 January 2015 at 00:12:35 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: In D, if a type is not marked as shared, then it is by definition thread-local, and the

Re: cannot modify struct with immutable members

2015-01-03 Thread ketmar via Digitalmars-d-learn
On Sat, 03 Jan 2015 01:00:58 -0800 Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 01/02/2015 09:07 PM, ketmar via Digitalmars-d-learn wrote: structure instance with const fields can be initialized only once, upon creation. so did `Test myTest1;` -- you

Re: cannot modify struct with immutable members

2015-01-02 Thread ketmar via Digitalmars-d-learn
On Sat, 03 Jan 2015 14:45:24 +1030 ted via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Well, I just cleared up some of my misunderstanding. I did not realise the mA (within struct Test) would be a _copy_ of arg, not a reference (pointer) to arg. So the more correct code

Re: cannot modify struct with immutable members

2015-01-02 Thread ketmar via Digitalmars-d-learn
On Sat, 03 Jan 2015 15:56:58 +1030 ted via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Ironically, I'm trying to use const in an effort to understand it...but there seems to be an unusual amount of pain until I grok it. just remember that `const` infects everything down to the

Re: cannot modify struct with immutable members

2015-01-02 Thread ketmar via Digitalmars-d-learn
On Sat, 03 Jan 2015 16:40:14 +1030 ted via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I'm now taking the view that const is there for the compiler to optimise code on the basis that nothing can alter it once set (and can only be set on initialisation). So I see your point

Re: cannot modify struct with immutable members

2015-01-02 Thread ketmar via Digitalmars-d-learn
On Sat, 03 Jan 2015 14:45:24 +1030 ted via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: p.s. also please note that structs in D are always passed by value and copied (until you not explicitly ask for something another). so: MyStruct a; MyStruct b; b = a; actually does

Re: cannot modify struct with immutable members

2015-01-02 Thread ketmar via Digitalmars-d-learn
On Sat, 03 Jan 2015 13:25:31 +1030 ted via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I get the following error from the code below: (dmd2.066.1, linux) test.d(26): Error: cannot modify struct myTest1 Test with immutable members Is this expected? If so, how can I

Re: Scoped external function declaration

2015-01-02 Thread ketmar via Digitalmars-d-learn
On Fri, 02 Jan 2015 10:40:22 + novice2 via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Thanx Daniel, thanx Ketmar. I just thinked that this is some sort of bug. May be DMD should not change mangled name of external function... Bit i dont know. with `extern(C)` it

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread ketmar via Digitalmars-d-learn
On Thu, 01 Jan 2015 12:32:33 + Idan Arye via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: If I have an associative array and I only modify it's values, without changing the keys, can I assume that the order won't change? please, don't: this is implementation-specific.

Re: Scoped external function declaration

2015-01-01 Thread ketmar via Digitalmars-d-learn
On Thu, 01 Jan 2015 17:51:45 + novice2 via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I want to use external or C function. It used only one time from one D function. I want do declare C function inside D function. I don't want to declare C function in global scope.

Re: regex on binary data

2014-12-31 Thread ketmar via Digitalmars-d-learn
On Wed, 31 Dec 2014 15:36:16 + Darrell via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: So far attempts to run regex on binary data causes Invalid UTF-8 sequence. Attempts to pass ubyte also didn't work out. current regex engine assumes that you are using UTF-8 encoded

Re: getting current DateTime

2014-12-30 Thread ketmar via Digitalmars-d-learn
On Wed, 31 Dec 2014 06:03:04 + bitwise via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: How do you get the current DateTime? Why doesn't DateTime have DateTime.now? but it has! ;-) auto now = cast(DateTime)Clock.currTime; signature.asc Description: PGP signature

Re: `shared Mutex`?

2014-12-28 Thread ketmar via Digitalmars-d-learn
On Sun, 28 Dec 2014 20:21:45 + Aiden via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Thanks for the information. At least I've discovered a reasonably tidy way of wrapping Mutex up so that it's not quite as painful casting everything: shared class SharedMutex {

Re: Order of evaluation of post-increment operator

2014-12-28 Thread ketmar via Digitalmars-d-learn
On Sun, 28 Dec 2014 17:34:50 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Sunday, 28 December 2014 at 16:05:32 UTC, bearophile wrote: (IMHO it must be). Disallowing is an alternative to consider. Even defined behaviour can be unintuitive and error prone. yep,

Re: opDollar and length

2014-12-28 Thread ketmar via Digitalmars-d-learn
On Sun, 28 Dec 2014 19:02:59 +0100 Joseph Rushton Wakeling via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: A question that suddenly occurred to me, and I realized I didn't know the answer. Why is it necessary/desirable to define separate .length and .opDollar methods

Re: Problem with immutables and Template typeof(this)

2014-12-28 Thread ketmar via Digitalmars-d-learn
On Sun, 28 Dec 2014 14:07:18 -0800 AuoroP via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: let me give you a riddle: struct ExampleTemplate(T) { T value; auto opAdd (typeof(this) that) inout { import std.traits : Unqual; Unqual!(typeof(this)) result;

Re: Importing a module from another directory

2014-12-27 Thread ketmar via Digitalmars-d-learn
On Sat, 27 Dec 2014 17:38:55 + Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Saturday, 27 December 2014 at 17:36:39 UTC, Derix wrote: What am I missing ? Or, to put it more simply, what would be the correct dmd command line to import a module defined

Re: nogc associative array?

2014-12-27 Thread ketmar via Digitalmars-d-learn
On Sat, 27 Dec 2014 23:43:54 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Is there a way to do something like this while keeping the destructor nogc? class Foo { shared static Foo[id] registry; int id; this(int id) { this.id =

Re: nogc associative array?

2014-12-27 Thread ketmar via Digitalmars-d-learn
On Sat, 27 Dec 2014 23:43:54 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Is there a way to do something like this while keeping the destructor nogc? class Foo { shared static Foo[id] registry; int id; this(int id) { this.id =

Re: Constructor protection: package ctors, UFCS, static methods?

2014-12-27 Thread ketmar via Digitalmars-d-learn
On Sat, 27 Dec 2014 23:34:06 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 26 December 2014 at 15:58:18 UTC, aldanor wrote: Please ignore the missing new keywords in the code and other minor typos :) Any opinions please?.. Would be much

Re: [std.net.curl] Downloading multiple files using download()

2014-12-27 Thread ketmar via Digitalmars-d-learn
On Sun, 28 Dec 2014 06:14:09 + Jack via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I'm trying to create a sort of downloader where it will download multiple pages of comics which are in .jpg format. Now the problem is, that when I used the download() function:

Re: [std.net.curl] Downloading multiple files using download()

2014-12-27 Thread ketmar via Digitalmars-d-learn
On Sun, 28 Dec 2014 06:51:14 + Jack via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: As much as my brotherhood senses push me into revealing the links(they're in json), doing that will reveal my guilty pleasures and fetishes. Well, anywho, thanks for that. I appreciate

Re: [std.net.curl] Downloading multiple files using download()

2014-12-27 Thread ketmar via Digitalmars-d-learn
On Sun, 28 Dec 2014 07:24:53 + Jack via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Well it's not really that much of a link really. I swear. It's just like fapping to drawings or some sort of thing. Not really THAT good of a comic. *sweats* so that's not one of that

Re: [std.net.curl] Downloading multiple files using download()

2014-12-27 Thread ketmar via Digitalmars-d-learn
On Sun, 28 Dec 2014 07:44:33 + Jack via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: How does one compile for Windows on a Linux Machine using dub? I've been using the platform : [windows] configuration in my dub.json to no avail since my Windows installation keeps on

Re: Throw an exception but hide the top frame?

2014-12-24 Thread ketmar via Digitalmars-d-learn
On Wed, 24 Dec 2014 13:38:59 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Imagine there's a template that wraps arbitrary functions and may throw exceptions depending on their returned values (see a simplified example below). However, if an exception occurs,

Re: Throw an exception but hide the top frame?

2014-12-24 Thread ketmar via Digitalmars-d-learn
On Wed, 24 Dec 2014 14:04:50 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Wednesday, 24 December 2014 at 13:48:26 UTC, ketmar via Digitalmars-d-learn wrote: the `object.Exception@wrap.d` is not a backtrace result, this is the result of Exception

Re: Throw an exception but hide the top frame?

2014-12-24 Thread ketmar via Digitalmars-d-learn
has to generate new parameterized function, of course. sorry. signature.asc Description: PGP signature

Re: Enum template with mixin, need 'this'

2014-12-24 Thread ketmar via Digitalmars-d-learn
On Wed, 24 Dec 2014 17:05:45 + Meta via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: So `if (isSet!bit1)` becomes `if (cast(bool)(embeddedTest.bits bit1)`. That doesn't work, however. I get an error message saying need 'this' for 'bits' of type 'int'. Is there a way to

Re: Enum template with mixin, need 'this'

2014-12-24 Thread ketmar via Digitalmars-d-learn
On Wed, 24 Dec 2014 19:52:31 + Meta via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hmm, I confused myself over when the expression is interpreted. I got it into my head that the template expansion would somehow delay interpretation of the expression so it could be

Re: Templates, constructors and default arguments

2014-12-24 Thread ketmar via Digitalmars-d-learn
On Thu, 25 Dec 2014 02:07:51 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I'm wondering how to best implement the following pattern: the constructor of a class has some required and some optional arguments; and one of the (optional) arguments also controls

Re: Templates, constructors and default arguments

2014-12-24 Thread ketmar via Digitalmars-d-learn
On Thu, 25 Dec 2014 03:07:55 + aldanor via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 25 December 2014 at 02:28:47 UTC, ketmar via Digitalmars-d-learn wrote: happy hacking! ;-) Thanks once again! I think this mostly solves it. Would it be possible

Re: Is D's GC.calloc and C's memset played the same role?

2014-12-23 Thread ketmar via Digitalmars-d-learn
On Tue, 23 Dec 2014 15:37:12 + FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: you will find the different: D: PROCESSENTRY32* pe32 = cast(PROCESSENTRY32*)GC.calloc(PROCESSENTRY32.sizeof); C++:PROCESSENTRY32 pe32; GC.calloc means: memset ?! do you see

Re: Storing arrays as Variant types.

2014-12-23 Thread ketmar via Digitalmars-d-learn
On Tue, 23 Dec 2014 22:57:07 + Winter M. via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I've run into a problem while trying to coerce array values from a variant; specifically, char[] a = aVariant.coerce!(char[]); // This works just fine. byte[] b =

Re: Is D's GC.calloc and C's memset played the same role?

2014-12-23 Thread ketmar via Digitalmars-d-learn
On Wed, 24 Dec 2014 00:24:44 + FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Tuesday, 23 December 2014 at 20:22:12 UTC, ketmar via Digitalmars-d-learn wrote: On Tue, 23 Dec 2014 15:37:12 + FrankLike via Digitalmars-d-learn digitalmars-d-learn

Re: How to Declare a new pragma ?

2014-12-21 Thread ketmar via Digitalmars-d-learn
On Sun, 21 Dec 2014 16:42:45 + FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I want to get that : pragma(link, SUBSYSTEM WINDOWS,4.0); But get error:pragma link unrecognized pragma(link)? How can I to do? Thank you. you have to patch the compiler to

Re: std.file.readText() extra Line Feed character

2014-12-19 Thread ketmar via Digitalmars-d-learn
On Fri, 19 Dec 2014 10:22:01 + Colin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 18 December 2014 at 22:29:30 UTC, Ali Çehreli wrote: On 12/18/2014 02:51 AM, Colin wrote: vi, and it does indeed have a '\n' at the end of file. Ah, I see. That's

Re: std.file.readText() extra Line Feed character

2014-12-19 Thread ketmar via Digitalmars-d-learn
On Fri, 19 Dec 2014 10:22:01 + Colin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 18 December 2014 at 22:29:30 UTC, Ali Çehreli wrote: On 12/18/2014 02:51 AM, Colin wrote: vi, and it does indeed have a '\n' at the end of file. Ah, I see. That's

Re: Loops versus ranges

2014-12-19 Thread ketmar via Digitalmars-d-learn
On Fri, 19 Dec 2014 10:41:03 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Can you tell why? :-) 'cause lazy ranges can't be optimised in compile time? ;-) signature.asc Description: PGP signature

Re: Loops versus ranges

2014-12-19 Thread ketmar via Digitalmars-d-learn
On Fri, 19 Dec 2014 12:20:34 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: anon: Changed to return data.map!(n = foo2(data, i + 1, max)).cache.joiner.array; then it produced the same result as array version. `map.cache.join` resulted in

<    2   3   4   5   6   7   8   9   10   11   >