Re: D1 operator overloading in D2

2015-03-30 Thread ketmar via Digitalmars-d-learn
On Mon, 30 Mar 2015 11:25:01 -0400, Steven Schveighoffer wrote: here is ER with patches: https://issues.dlang.org/show_bug.cgi?id=14382 sorry for breaking my promise of not making ERs anymore. ;-) signature.asc Description: PGP signature

Re: using exceptions in @nogc

2015-03-30 Thread ketmar via Digitalmars-d-learn
On Tue, 31 Mar 2015 05:34:11 +, weaselcat wrote: On Tuesday, 31 March 2015 at 03:12:42 UTC, ketmar wrote: On Tue, 31 Mar 2015 01:40:52 +, weaselcat wrote: was this ever solved? nope. there were some suggestions, but no decision was made. sigh do you know if there's an open

Re: Mutual optimization of tail recursion does not work in D

2015-03-31 Thread ketmar via Digitalmars-d-learn
On Tue, 31 Mar 2015 11:57:49 +, w0rp wrote: You might want to try GDC or LDC. I am not certain if they implement tail call optimisations, but they might do, and it seems like a good optimisation to have. I'm sure this has been discussed before. gdc does, as this is gcc backend

Re: reinterpret_cast float to uint

2015-03-29 Thread ketmar via Digitalmars-d-learn
On Sun, 29 Mar 2015 16:00:05 +, matovitch wrote: On Sunday, 29 March 2015 at 14:50:24 UTC, ketmar wrote: On Sun, 29 Mar 2015 13:45:10 +, matovitch wrote: you can also use unions. Good idea ! In my case I think it was better to cast, but this could be helpful another time thanks !

Re: GC deadlocks on linux

2015-02-27 Thread ketmar via Digitalmars-d-learn
On Sat, 28 Feb 2015 06:09:16 +0100, Martin Nowak wrote: Meanwhile the author of daemonized came up with another idea, using exec instead of fork. https://github.com/NCrashed/daemonize/issues/2 ahem. http://forum.dlang.org/post/mc35ap$2dvo$5...@digitalmars.com signature.asc Description: PGP

Re: Does static ctor/dtor of struct behave differently in 2.067-b2?

2015-02-27 Thread ketmar via Digitalmars-d-learn
On Fri, 27 Feb 2015 23:58:16 +, amber wrote: On Friday, 27 February 2015 at 23:50:51 UTC, amber wrote: Hi All, [snip] Thanks, amber [edited subject] Sorry I should add that I'm talking about static ctor/dtor of struct. The bug I see with 2.067-b2 is this: 1. static this() {}

Re: strage heisenbug (has scoped destruction, cannot build closure)

2015-03-02 Thread ketmar via Digitalmars-d-learn
p.p.s. sure, i can see where i'm creating a closure. but i can't see how that closure got to IR generator, as it is never executes, there is no need to generate code for it, and it should be removed after checking `static if` condition. signature.asc Description: PGP signature

strage heisenbug (has scoped destruction, cannot build closure)

2015-03-02 Thread ketmar via Digitalmars-d-learn
hi. the following (manually dustmited ;-)) code gives the error from subj on git HEAD: === ztest.d === module ztest; auto streamAsRange(STP) (STP st) { static struct StreamRange(ST) { private: ST strm; public: void put (const(ubyte)[] data) { strm.rawWrite(data); }

Re: Implicit fall through not detected (Example from lex.html)

2015-03-02 Thread ketmar via Digitalmars-d-learn
On Tue, 03 Mar 2015 06:58:14 +, Andre wrote: Hi, I am little bit confused. I am copied the switch example from lex.html and expected that case 6 will lead to a syntax error due to the missing break statement. But the example compiles without error (C:dmd app) implicit fallthru is not a

Re: strage heisenbug (has scoped destruction, cannot build closure)

2015-03-02 Thread ketmar via Digitalmars-d-learn
p.s. well, it's not a heisenbug, 'cause it reproducible. let's say that it's a... very strange bug. ;-) signature.asc Description: PGP signature

Re: GC deadlocks on linux

2015-03-02 Thread ketmar via Digitalmars-d-learn
On Mon, 02 Mar 2015 08:15:12 +, Kagamin wrote: On Saturday, 28 February 2015 at 05:32:51 UTC, ketmar wrote: On Sat, 28 Feb 2015 06:09:16 +0100, Martin Nowak wrote: Meanwhile the author of daemonized came up with another idea, using exec instead of fork.

Re: D constness: head tail

2015-03-02 Thread ketmar via Digitalmars-d-learn
or, tl;dr: `const` in D is working as it was designed to work. there are no changes planning for it, and it will not be turned to c++-like const. signature.asc Description: PGP signature

Re: D constness: head tail

2015-03-02 Thread ketmar via Digitalmars-d-learn
On Mon, 02 Mar 2015 11:33:00 +, Tobias Pankrath wrote: It's working as it's designed to work, although the design is somewhat lacking: yeah, i didn't mean that the design is best possible one, but it's set in stone for now. signature.asc Description: PGP signature

Re: Error instantiating std.container.Array

2015-03-02 Thread ketmar via Digitalmars-d-learn
On Mon, 02 Mar 2015 14:40:50 +, Francesco Cattoglio wrote: did you tried to dustmite[1] it? [1] https://github.com/CyberShadow/DustMite/wiki signature.asc Description: PGP signature

Re: Cycle detected between modules with ctors/dtors

2015-03-04 Thread ketmar via Digitalmars-d-learn
On Wed, 04 Mar 2015 11:06:50 -0500, Steven Schveighoffer wrote: Clearly, the above is not an issue, but at the moment, the code treats having a ctor and having a dtor as the same thing. How to fix it? I'm not exactly sure, you need to have the modules sorted according to ctor and also

Re: I want to introduce boost_asio to dlang

2015-03-04 Thread ketmar via Digitalmars-d-learn
On Thu, 05 Mar 2015 06:05:55 +, zhmt wrote: But I am not familiar with dlang this is the root of the problem. please, make yourself familiar before starting to wrap boost crap. you may find that you don't need it at all. signature.asc Description: PGP signature

Re: ErrnoException in Windows

2015-03-01 Thread ketmar via Digitalmars-d-learn
On Sun, 01 Mar 2015 16:39:27 +, novice2 wrote: Could you, please, help me to understand, why code: 'cause winapi functions never sets `errno`. `errno` is a libc feature, and winapi knows nothing about libc. besides, `GetLastError()` is not required to return correct errno codes. so you

Re: I want to introduce boost_asio to dlang

2015-03-05 Thread ketmar via Digitalmars-d-learn
On Thu, 05 Mar 2015 07:46:04 +, zhmt wrote: I have studied for half a year, so I want to learn it in work, in solving problems. that's a good way to learn. but starting from writing wrappers for something is not a good way. ;-) if you want a wrapper for something, it's always better to

Re: const member function

2015-02-23 Thread ketmar via Digitalmars-d-learn
On Mon, 23 Feb 2015 09:12:33 +, rumbu wrote: On Saturday, 21 February 2015 at 15:26:28 UTC, ketmar wrote: On Sat, 21 Feb 2015 08:27:13 +, rumbu wrote: My question was not how I do this, I know already. My question was if there is another way to safely call a non-const instance

Re: How can I do that in @nogc?

2015-02-25 Thread ketmar via Digitalmars-d-learn
On Wed, 25 Feb 2015 20:36:32 +, Namespace wrote: That last thing works. But I have no clue why. o.O Anyway, thanks a lot! this is a smart hack. that should be NEVER used in production code. anyway, it's good that you don't understand it. your code will crash sooner or later, and you will

Re: Best practices for reading public interfaces

2015-02-22 Thread ketmar via Digitalmars-d-learn
On Sun, 22 Feb 2015 16:12:49 +, Kenny wrote: On Saturday, 21 February 2015 at 20:56:26 UTC, anonymous wrote: On Saturday, 21 February 2015 at 20:46:09 UTC, Kenny wrote: b) Write DDocs and read documentation. The problem here is that I'm going to use D only for my own projects and in the

Re: Is this a bug in dmd 2.067 for struct initializers?

2015-02-22 Thread ketmar via Digitalmars-d-learn
On Mon, 23 Feb 2015 02:15:08 +, stewarth wrote: On Monday, 23 February 2015 at 02:10:09 UTC, amber wrote: On Sunday, 22 February 2015 at 23:17:33 UTC, Martin Nowak wrote: On Thursday, 19 February 2015 at 22:07:55 UTC, stewarth wrote: I've gone with static this() approach and it works.

Re: how to stop a variable from being optimized out

2015-02-23 Thread ketmar via Digitalmars-d-learn
On Tue, 24 Feb 2015 06:29:33 +, Rory wrote: Is there a way I can stop current from being optimized out without using volatile? but why do you need this? just use `atomicLoad` to get shared variable value, it will do the right caching. signature.asc Description: PGP signature

Re: Struct inheritance

2015-02-24 Thread ketmar via Digitalmars-d-learn
On Tue, 24 Feb 2015 12:05:50 +, amber wrote: Hi, Is it possible in D to have inheritance using value types, i.e. structs? Also I don't quite understand how copy ctors work in D. Do I need to implement opAssign(S other) {}, or this(this) {} and what's the difference between these two?

Re: Struct inheritance

2015-02-24 Thread ketmar via Digitalmars-d-learn
On Tue, 24 Feb 2015 18:19:39 +, ketmar wrote: On Tue, 24 Feb 2015 12:05:50 +, amber wrote: Hi, Is it possible in D to have inheritance using value types, i.e. structs? Also I don't quite understand how copy ctors work in D. Do I need to implement opAssign(S other) {}, or

Re: Struct inheritance

2015-02-24 Thread ketmar via Digitalmars-d-learn
On Tue, 24 Feb 2015 12:05:50 +, amber wrote: Hi, Is it possible in D to have inheritance using value types, i.e. structs? Also I don't quite understand how copy ctors work in D. Do I need to implement opAssign(S other) {}, or this(this) {} and what's the difference between these two?

Re: how to stop a variable from being optimized out

2015-02-24 Thread ketmar via Digitalmars-d-learn
On Tue, 24 Feb 2015 12:50:53 +, Rory wrote: On Tuesday, 24 February 2015 at 06:48:26 UTC, ketmar wrote: but why do you need this? just use `atomicLoad` to get shared variable value, it will do the right caching. Nice! Thanks. Tested atomicLoad and it is slightly faster for my non

Re: const member function

2015-02-21 Thread ketmar via Digitalmars-d-learn
On Sat, 21 Feb 2015 08:27:13 +, rumbu wrote: My question was not how I do this, I know already. My question was if there is another way to safely call a non-const instance function on a const object. is there a way to been safely hit by a truck? signature.asc Description: PGP signature

Re: GC deadlocks on linux

2015-02-20 Thread ketmar via Digitalmars-d-learn
On Fri, 20 Feb 2015 22:29:04 +, Ola Fosheim Grøstad wrote: This robust philosophy somehow got lost in the quest for bleeding edge. i still missing it. sure, we can write our code in this style today, but with all that libraries that can create threads without you knowing about it (heh,

Re: static void arrays under garbage control?

2015-02-25 Thread ketmar via Digitalmars-d-learn
On Wed, 25 Feb 2015 20:20:37 -0600, captaindet wrote: On 2015-02-25 19:24, Adam D. Ruppe wrote: does this warning only apply to dynamic void[] arrays but not to static void[CTconstant] arrays? Both of those will be scanned for pointers. thanks, adam, so i should always use struct

Re: How can I do that in @nogc?

2015-02-25 Thread ketmar via Digitalmars-d-learn
On Wed, 25 Feb 2015 21:32:02 +, Namespace wrote: Instead of some wise talk, you could simply explain it. ;) i can, but i certainly don't want to. many people are reading this forum, and i don't want to teach 'em something like this. signature.asc Description: PGP signature

Re: How can I do that in @nogc?

2015-02-25 Thread ketmar via Digitalmars-d-learn
On Wed, 25 Feb 2015 21:32:02 +, Namespace wrote: The code is only used for debugging purposes. the best way to make your program undebugable is to use debugging code that will be turned off in production. this way you aren't debugging the code that will go into production, you debugging

Re: Problem overloading operator for a struct with an immutable member

2015-03-26 Thread ketmar via Digitalmars-d-learn
On Thu, 26 Mar 2015 05:44:13 +, Jean pierre wrote: auto i = s++; // OUCH, but we expect S.i... but why one expecting `i` here? there IS `opUnary` overload, and `++` corretly transformed to prefix form. there is simply NO postfix form in semantically analyzed code, *all* postfix

Re: Problem overloading operator for a struct with an immutable member

2015-03-25 Thread ketmar via Digitalmars-d-learn
On Tue, 24 Mar 2015 16:49:01 +, Nicolas Sicard wrote: I don't know if this is a bug or expected behaviour. The struct is mutable, assignable and pre-increment operator works. But post-increment doesn't compile because of the immutable member. -- struct S { int i;

Re: Problem overloading operator for a struct with an immutable member

2015-03-25 Thread ketmar via Digitalmars-d-learn
On Tue, 24 Mar 2015 16:49:01 +, Nicolas Sicard wrote: I don't know if this is a bug or expected behaviour. The struct is mutable, assignable and pre-increment operator works. But post-increment doesn't compile because of the immutable member. -- struct S { int i;

Re: using the full range of ubyte with iota

2015-01-25 Thread ketmar via Digitalmars-d-learn
On Sun, 25 Jan 2015 20:42:47 +, Dominikus Dittes Scherkl wrote: But in a function you need the cast anyway: ubyte swapNibbles(ubyte x) { return (x4) | (x4); } // compiler not happy sure, it can't be happy, as `x` is promoted to int in the expression, so the expression result is `int`.

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: core.exception.InvalidMemoryOperationError@(0)

2015-01-25 Thread ketmar via Digitalmars-d-learn
On Sun, 25 Jan 2015 22:06:26 +, Bayan Rafeh wrote: This is another problematic example program: import std.stdio; void main(){ auto a = new A(/tmp/invalid); } class A { File f; string path; this(string path) { this.path = path; //f =

Re: core.exception.InvalidMemoryOperationError@(0)

2015-01-25 Thread ketmar via Digitalmars-d-learn
On Sun, 25 Jan 2015 22:06:26 +, Bayan Rafeh wrote: p.s. yet creating new `File` in invariant is wrong nevertheless, as it changes the program state. invariant checks SHOULD NEVER CHANGE THE PROGRAM STATE. signature.asc Description: PGP signature

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: Template reference parameter

2015-03-23 Thread ketmar via Digitalmars-d-learn
On Mon, 23 Mar 2015 22:01:03 +, rumbu wrote: I'm trying to construct a struct template where one of the template parameters is passed by reference (as option) struct S(T, U) { void opCall(T t, U u) { } } alias X = S!(T, U); alias RX = S!(T, ref U); //not working The

Re: Template reference parameter

2015-03-23 Thread ketmar via Digitalmars-d-learn
On Mon, 23 Mar 2015 22:39:27 +, rumbu wrote: It's working, but I don't like the value thing, ref would be better. alas. you can write a complex mixin that will generate the appropriate templates for you, though, so you'll be able to do something like this:

Re: Template reference parameter

2015-03-23 Thread ketmar via Digitalmars-d-learn
On Tue, 24 Mar 2015 00:54:12 +, weaselcat wrote: On Monday, 23 March 2015 at 22:39:28 UTC, rumbu wrote: I have only one template and I think it's impossible to define specializations since it's supposed that a random member of A... will be passed sometime by reference: auto ref?

Re: lambda code

2015-04-01 Thread ketmar via Digitalmars-d-learn
On Tue, 31 Mar 2015 13:25:46 +, John Colvin wrote: Short answer: no. .codeof for functions is something I've wanted for ages, but no movement so far. 'cause `.codeof` is a can of worms. it is just a bad replace for AST macros, and having it means that internal string representation should

Re: Templates: Array slices not recognized

2015-04-20 Thread ketmar via Digitalmars-d-learn
On Mon, 20 Apr 2015 10:14:25 +, Chris wrote: string a = bla; string b = blub; auto res = doSomething(a, b); If I didn't use auto ref or ref, string would get copied, wouldn't it? no, it wont -- not unless you'll append something to it. slicing arrays (and string is array too) will

Re: CT-String as a Symbol

2015-04-20 Thread ketmar via Digitalmars-d-learn
On Mon, 20 Apr 2015 13:31:03 +, Nordlöw wrote: On Thursday, 16 April 2015 at 18:12:35 UTC, Nordlöw wrote: Is there a way to CT-query the arity of all opIndex and opSlice overloads? Ping. as long as they aren't templates, you can use any function traits on 'em. like

Re: setjmp / longjmp

2015-04-26 Thread ketmar via Digitalmars-d-learn
On Sat, 25 Apr 2015 23:25:13 +, Cassio Butrico wrote: Hello everyone , first congratulations for the wonderful forum , I wish someone could help me , I am writing a small basic interpreter in D and I am with some difficulties. estoutentando manupular the setjmp / longjmp buffers , but

Re: Observing exceptions in a destructor

2015-04-21 Thread ketmar via Digitalmars-d-learn
On Wed, 22 Apr 2015 01:02:15 +, Mark Isaacson wrote: I'd like to be able to know if my destructor is being called because an exception was thrown. Any way to do that? sorry, you can't. signature.asc Description: PGP signature

Re: Adding pointers to GC with destructers

2015-04-19 Thread ketmar via Digitalmars-d-learn
On Sun, 19 Apr 2015 23:38:47 +, Freddy wrote: C libraries have a pattern of HiddenType* getObj(); void freeObj(HiddenType*); Is there any way I can make the GC search for a HiddenType* and run freeObj when the pointer is not found. wrap it in class/struct and run `freeObj()`

shouldn't this code at least trigger a warning?

2015-04-29 Thread ketmar via Digitalmars-d-learn
subj. the code: void main () { import std.stdio; char ch = '!'; switch (ch) { int n = 42; case '!': writeln(n, : wow!); break; default: } } i think that such abomination should: 1. be forbidden, or 2. trigger a warning, or 3. execute initializer anyway.

Re: shouldn't this code at least trigger a warning?

2015-04-30 Thread ketmar via Digitalmars-d-learn
On Wed, 29 Apr 2015 10:48:36 +, Gary Willoughby wrote: Please raise an issue in bugzilla. This is obviously an error. done: https://issues.dlang.org/show_bug.cgi?id=14532 signature.asc Description: PGP signature

Re: shouldn't this code at least trigger a warning?

2015-04-30 Thread ketmar via Digitalmars-d-learn
On Wed, 29 Apr 2015 07:57:07 -0700, H. S. Teoh via Digitalmars-d-learn wrote: Switch statements in D allow all sorts of abominations, if only you would try it. I think it was originally designed to support a particular loop idiom (sorry I forgot what it was called, and don't have time to look

Re: setjmp / longjmp

2015-04-27 Thread ketmar via Digitalmars-d-learn
On Sun, 26 Apr 2015 21:45:41 +0100, Stewart Gordon wrote: On 26/04/2015 06:56, ketmar wrote: snip you shouldn't use setjmp/longjmp in D. use exceptions instead. something like this: snip True in the general case. Still, there must be some reason that trying it in D causes an AV (even if

Re: UDA and ReturnType!(__traits...) doesn't work

2015-05-03 Thread ketmar via Digitalmars-d-learn
On Sun, 03 May 2015 17:21:58 +, filcuc wrote: Hi all, i'm working in the generation of the code but i'm failing in extracting a function return type when invoking the ReturnType!(T) type trait and mixing it with __traits(getMember) function. Can anyone help me? or explaining what is

Re: CTFE enums static assert

2015-05-04 Thread ketmar via Digitalmars-d-learn
On Mon, 04 May 2015 18:21:59 +0200, Robert M. Münch wrote: I find this a bit strange: // get all rules that start with p... enum BolRules = StaticFilter!(beginsWithP, __traits(allMembers,BolSource)); static assert(is(BolRules == enum)); Compiling using dmd... source/app.d(114): Error:

Re: Struct lifetime wrt function return?

2015-05-03 Thread ketmar via Digitalmars-d-learn
On Mon, 04 May 2015 02:29:19 +, rsw0x wrote: This says Goodbye! exactly once, indicating(?) that S was NRVO'd which means the scope of s went from foo to main. However, is this a guarantee by the standard? Is an implementation allowed to define foo such that it returns by copy and calls a

Re: Is this expected? default to public members in private class

2015-05-03 Thread ketmar via Digitalmars-d-learn
On Sun, 03 May 2015 18:07:20 -0700, Dan Olson wrote: It seems a private class or struct defaults to public members. Just curious if this is intended. I would have expected private all the way down unless overriden. i bet it is intended. protection of struct/class members is independed of

Re: UDA and ReturnType!(__traits...) doesn't work

2015-05-03 Thread ketmar via Digitalmars-d-learn
On Sun, 03 May 2015 18:02:37 +, filcuc wrote: Yep sorry, i'm still learning :) i'm not blaming you at all. what i mean i that i'm bad at explanations, so you'd better read one of the D books to better understand my cryptic don't do that, do this comments. ;-) signature.asc Description:

Re: CTFE enums static assert

2015-05-04 Thread ketmar via Digitalmars-d-learn
On Mon, 04 May 2015 20:07:27 +0200, Robert M. Münch wrote: Gives this: (string, string, string) playground.d(9): Error: no type for typeid(members1) playground.d(9):while evaluating pragma(msg, typeid(members1)) `typeid` is runtime thing, you can't use it in compile-time.

Re: Signs by which to recognize D1

2015-05-07 Thread ketmar via Digitalmars-d-learn
On Wed, 06 May 2015 14:26:43 +, rumbu wrote: operator overloads: opCom, opAdd, opSub ... phobos' std.xml, std.variand and std.bitmanip are D1! ;-) signature.asc Description: PGP signature

Re: ICE?

2015-05-18 Thread ketmar via Digitalmars-d-learn
On Sun, 17 May 2015 10:09:10 +, Daniel Kozak wrote: On Sunday, 17 May 2015 at 09:25:33 UTC, Namespace wrote: Is this error an ICE? I think so, because I see the internal filename, but I'm not sure. Error: e2ir: cannot cast malloc(length * 8u) of type void* to type char[] I would say

Re: -vgc Info ok?

2015-05-18 Thread ketmar via Digitalmars-d-learn
On Mon, 18 May 2015 14:30:42 +, Chris wrote: The following string[string] myarray = [key:value]; string entry; entry = myarray[key]; // = vgc: indexing an associative array may cause GC allocation Why is _accessing_ an assoc treated as indexing it? it can throw out of range error,

Re: -vgc Info ok?

2015-05-18 Thread ketmar via Digitalmars-d-learn
On Mon, 18 May 2015 14:41:19 +, Chris wrote: On Monday, 18 May 2015 at 14:34:38 UTC, ketmar wrote: On Mon, 18 May 2015 14:30:42 +, Chris wrote: The following string[string] myarray = [key:value]; string entry; entry = myarray[key]; // = vgc: indexing an associative array may

Re: Associative array on the heap

2015-05-18 Thread ketmar via Digitalmars-d-learn
On Mon, 18 May 2015 23:55:38 +, Freddy wrote: How do you allocate an associative array on the heap? void main(){ alias A=int[string]; auto b=new A; } $ rdmd test test.d(4): Error: new can only create structs, dynamic arrays or class objects, not int[string]'s

Re: CTFE UFCs?

2015-04-14 Thread ketmar via Digitalmars-d-learn
On Tue, 14 Apr 2015 11:20:38 -0400, bitwise wrote: i believe that you can't do what you want in a way you want, 'cause UFCS is not working for template args. but you can do this: alias base(alias CC) = reflect!(CC.baseName()); ... static const(Refl) baseRefl = base!refl; signature.asc

Re: About @ and UDA

2015-04-15 Thread ketmar via Digitalmars-d-learn
On Wed, 15 Apr 2015 08:53:05 +, Andrea Fontana wrote: My 2 cents. If I remember correctly, @ prefix in @safe, @trusted, @system, etc was added just to avoid keywords pollution, right? Now UDA uses the same prefix: if some new keywords/properties/attributes will be added to D, the same

Re: writefln patterns with mismatching compile-time known number of arguments

2015-04-13 Thread ketmar via Digitalmars-d-learn
On Sun, 12 Apr 2015 14:31:40 -0700, H. S. Teoh via Digitalmars-d-learn wrote: It's not hard to write a CTFE version of writef/writeln/etc., that takes the format argument at compile-time, since std.format itself is already CTFE-able. i didn't know that (didn't checked, actually), so i rewrote

Re: writefln patterns with mismatching compile-time known number of arguments

2015-04-12 Thread ketmar via Digitalmars-d-learn
On Sun, 12 Apr 2015 14:18:21 +, JR wrote: But the compiler has all the pieces of information needed to see it's wrong, doesn't it? no, it doesn't. compiler doesn't know about `std.format.format` and it's special abilities. while it is possible to add such checks to the compiler, it will

Re: why cant function parameters be grouped by type ?

2015-04-12 Thread ketmar via Digitalmars-d-learn
On Sun, 12 Apr 2015 11:49:18 +, Baz wrote: Is there anything in the grammar that prevents this syntax ? yes: nameless args. i would like to see 'em burned with napalm, but it seems to be too late to do that... signature.asc Description: PGP signature

Re: Where is COFFIMPLIB

2015-04-17 Thread ketmar via Digitalmars-d-learn
On Fri, 17 Apr 2015 19:48:05 +, rumbu wrote: On Friday, 17 April 2015 at 14:39:52 UTC, Adam D. Ruppe wrote: coffimplib is a paid utility out of the $15 extended utility package http://digitalmars.com/eup.html buy from here (be sure javascript is enabled or the form won't even appear)

Re: Where is COFFIMPLIB

2015-04-17 Thread ketmar via Digitalmars-d-learn
On Fri, 17 Apr 2015 20:05:42 +, rumbu wrote: On Friday, 17 April 2015 at 19:50:13 UTC, ketmar wrote: On Fri, 17 Apr 2015 19:48:05 +, rumbu wrote: On Friday, 17 April 2015 at 14:39:52 UTC, Adam D. Ruppe wrote: coffimplib is a paid utility out of the $15 extended utility package

Re: Templates: Array slices not recognized

2015-04-18 Thread ketmar via Digitalmars-d-learn
On Sat, 18 Apr 2015 17:50:56 +, Chris wrote: Doh! You're right! My bad. However, this makes the function less generic, but it doesn't matter here. maybe `auto ref` can help here? signature.asc Description: PGP signature

Re: Static if to compare two types are the exact same

2015-04-06 Thread ketmar via Digitalmars-d-learn
On Mon, 06 Apr 2015 19:16:33 +, Jonathan wrote: What's the best way to do this? I'm assuming this should be best practice: http://dlang.org/traits.html#isSame struct S { } writeln(__traits(isSame, S, S)); struct S {} auto s0 = S(); auto s1 = S(); static if (is(typeof(s0) ==

Re: -vgc Info ok?

2015-05-19 Thread ketmar via Digitalmars-d-learn
On Tue, 19 May 2015 11:36:32 +, Chris wrote: On Tuesday, 19 May 2015 at 11:08:52 UTC, thedeemon wrote: On Monday, 18 May 2015 at 14:30:43 UTC, Chris wrote: Why is _accessing_ an assoc treated as indexing it? Are you sure you understand indexing as we do? It's not like indexing of

Re: -vgc Info ok?

2015-05-19 Thread ketmar via Digitalmars-d-learn
On Tue, 19 May 2015 13:17:15 +, anonymous wrote: On Monday, 18 May 2015 at 14:34:38 UTC, ketmar wrote: it can throw out of range error, which is `new`ed. Array access can also throw RangeError, but -vgc and @nogc don't mind that: void main() @nogc { int[] a; auto b =

Re: Why is there no named parameter support?

2015-06-09 Thread ketmar via Digitalmars-d-learn
On Tue, 09 Jun 2015 09:50:15 +, Marc Schütz wrote: On Tuesday, 9 June 2015 at 05:39:06 UTC, Timothee Cour wrote: I'd be very interested in reading more about those reasons beyond FUD. The arguments in favor have been repeated many times over, and the only argument against that I've heard

Re: Why is there no named parameter support?

2015-06-09 Thread ketmar via Digitalmars-d-learn
On Mon, 08 Jun 2015 20:32:56 -0700, Jonathan M Davis via Digitalmars-d-learn wrote: is, but personally, I think that named arguments are a terrible idea in general, so I'm not about to try and support a position that tries to bring them into D. it's a perfect thing. i always hate that Flag

Re: Why is there no named parameter support?

2015-06-09 Thread ketmar via Digitalmars-d-learn
On Mon, 08 Jun 2015 22:58:10 -0700, Jonathan M Davis via Digitalmars-d-learn wrote: Personally, I hate how named arguments affect the API (e.g. the names of the parameters suddenly become part of the API), and for the most part, the only times that they're worth much is when you have so many

Re: setjmp / longjmp

2015-06-09 Thread ketmar via Digitalmars-d-learn
On Tue, 09 Jun 2015 11:57:03 +0100, Stewart Gordon wrote: On 27/04/2015 10:41, ketmar wrote: snip i believe this has something to do with exception frames. but it needs further investigation. What is an exception frame, exactly? to correctly do unwinding and other interesting things

Re: Casting MapResult

2015-06-15 Thread ketmar via Digitalmars-d-learn
On Mon, 15 Jun 2015 15:10:20 +, jmh530 wrote: you shouldn't cast it like that. use `std.array.array` to get the actual array. like this: import std.array; auto y = x.map!(a = exp(a)).array; the thing is that `map` returns so-called lazy range. lazy ranges trying to not do any work

Re: __traits getMember is context sensetive?

2015-06-14 Thread ketmar via Digitalmars-d-learn
On Sun, 14 Jun 2015 10:29:08 +, anonymous wrote: One important thing I didn't see stated clearly by anyone in here: CTFE may run at compile time but it follows the same rules as run time evaluation (plus some restrictions). This means, you can't use dynamic values (e.g. function

Re: __traits getMember is context sensetive?

2015-06-14 Thread ketmar via Digitalmars-d-learn
On Sun, 14 Jun 2015 09:46:54 +, JDemler wrote: On Sunday, 14 June 2015 at 05:52:00 UTC, ketmar wrote: oh, seems that i managed to make everything even less understandable... Your code works perfectly and makes at least some sense to me. Thank you. If i understand it correctly:

Re: More type-flexible arrays?

2015-06-14 Thread ketmar via Digitalmars-d-learn
p.s. faster weak typing solution is definitely possible if you'll narrow possible type set. but as i said, i'd not recommend to go this way. there can be dragon in the end. signature.asc Description: PGP signature

Re: how come is this legal? 'void fun(int){ }' ?

2015-06-13 Thread ketmar via Digitalmars-d-learn
On Sun, 14 Jun 2015 05:11:17 +, Maxim Fomin wrote: On Sunday, 14 June 2015 at 01:20:39 UTC, Timothee Cour wrote: I understand this is legal for declaration wo definition (void fun(int);) but why allow this: void test(int){} ? Actually it is void test(int _param_0) { } You can test by

Re: More type-flexible arrays?

2015-06-14 Thread ketmar via Digitalmars-d-learn
On Sun, 14 Jun 2015 06:12:29 +, Ozan wrote: Hallo! Is it possible to create arrays which has more then one type, f. ex. array[0] = 1; array[1] = z; array[2] = new clazz(), I tried Variant, but it slow down heavily my app. it is possible. with Variant. ;-) chances are that

Re: __traits getMember is context sensetive?

2015-06-13 Thread ketmar via Digitalmars-d-learn
oh, seems that i managed to make everything even less understandable... signature.asc Description: PGP signature

Re: __traits getMember is context sensetive?

2015-06-13 Thread ketmar via Digitalmars-d-learn
On Sat, 13 Jun 2015 23:55:53 +, JDemler wrote: After a bit of rethinking: I guess the compiler goes through 2 loops: the first resolves __traits, the second does ctfe. That would explain this behavior. a is not present to the compiler while it tries to resolve my __traits call, but

Re: @property on free function for UFCS?

2015-06-14 Thread ketmar via Digitalmars-d-learn
On Sun, 14 Jun 2015 12:26:52 +, rcorre wrote: Suppose I have a function defined like so: void foo(int i) { } intended to be called like: 5.foo Should it be labeled with @property? Or is @property only for true member functions? only if you plan to use it like `foo = 5;`. i.e.

Re: @property on free function for UFCS?

2015-06-14 Thread ketmar via Digitalmars-d-learn
On Sun, 14 Jun 2015 18:21:39 +0200, Timon Gehr wrote: only if you plan to use it like `foo = 5;`. You can use it like that anyway. sure, but i'm talking about style, not about compiler demands. i.e. exactly like field variable. struct S{ void delegate() dg; } int main(){

Re: Does anyone get line numbers in stack traces on Linux?

2015-06-17 Thread ketmar via Digitalmars-d-learn
i have that. with GCD. ;-) signature.asc Description: PGP signature

Re: Are stack+heap classes possible in D?

2015-06-17 Thread ketmar via Digitalmars-d-learn
On Wed, 17 Jun 2015 06:02:46 +, WhatMeWorry wrote: I guess the question would be why would one want a struct on the heap and a class on the stack? Performance reasons? struct on the heap: some containers, for example, doing their own memory management. class on the stack: guaranteed

Re: Defining constant values in struct

2015-06-17 Thread ketmar via Digitalmars-d-learn
On Wed, 17 Jun 2015 09:49:56 +0900, Mike Parker wrote: On 6/17/2015 6:17 AM, tcak wrote: As far as I known, when I define a string with enum and it is used at different parts of code, that string is repeated again and again in executable file instead of passing a pointer to string. So, using

Re: Conditional Compilation Multiple Versions

2015-06-13 Thread ketmar via Digitalmars-d-learn
On Sat, 13 Jun 2015 13:49:49 +, anonymous wrote: Taking it one step further: template Version(string name) { mixin( version(~name~) enum Version = true; else enum Version = false; ); } static if(Version!One || Version!Two) { ... } very

Re: Conditional Compilation Multiple Versions

2015-06-13 Thread ketmar via Digitalmars-d-learn
On Sat, 13 Jun 2015 12:01:29 -0400, bitwise wrote: nope. Walter is against that, so we'll not have it, despite the triviality of the patch. Any idea what the rationale was for not allowing it? i don't remember. that murmuring about it makes the code harder to read goes beyond me, so it's

Re: Conditional Compilation Multiple Versions

2015-06-13 Thread ketmar via Digitalmars-d-learn
On Fri, 12 Jun 2015 20:41:59 -0400, bitwise wrote: Is there a way to compile for multiple conditions? Tried all these: version(One | Two){ } version(One || Two){ } version(One Two){ } version(One) | version(Two){ } version(One) || version(Two){ } version(One) version(Two){ }

Re: __traits getMember is context sensetive?

2015-06-13 Thread ketmar via Digitalmars-d-learn
On Sat, 13 Jun 2015 10:36:39 +, John Colvin wrote: *for some reason it's not public, but it's very short and simple: it's funny how many useful things are there in Phobos, carefully hidden from user. i believe each D book should include an advice like this: to fully learn what you can do

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