Re: Best practices

2013-08-27 Thread JS
On Tuesday, 27 August 2013 at 21:30:53 UTC, H. S. Teoh wrote: On Tue, Aug 27, 2013 at 10:59:40PM +0200, JS wrote: There seems to be a lot of stuff D can do but no best practices for optimal code(performance or safety). Someone should write a book about it! I think we're aware of

Best practices

2013-08-27 Thread JS
There seems to be a lot of stuff D can do but no best practices for optimal code(performance or safety). Someone should write a book about it! e.g., The scope(this) thread... is that something I should start doing because it is much safer or what? A book with all the goodies inside it would m

Re: -gl for dmd

2013-08-13 Thread JS
On Wednesday, 14 August 2013 at 03:36:09 UTC, JS wrote: It would also be nice if symbols could demangled. It would be nice if I could roll my own but core.demangle only have works... int main.A.foo() __except_list _D17TypeInfo_C4main1A6__initZ _D17TypeInfo_C4main1B6__initZ @property int

Re: -gl for dmd

2013-08-13 Thread JS
It would also be nice if symbols could demangled.

-gl for dmd

2013-08-13 Thread JS
obj2asm says that adding -gl can give the source code line numbers in the asm dump. dmd does not seem to support this? Any way to get it added?

Re: Jquery SOB killer

2013-08-11 Thread JS
BTW, I hope that if you want to be added to the ignore list on my side, you use the script and do the same. I know some will want everyone to see their irrelevant posts but I won't see it and so you will never get a response from me and it just clutters up the NG and distracts from D.

Jquery SOB killer

2013-08-11 Thread JS
This goes out to all the SOB's out there. Thanks jQuery! // ==UserScript== // @name Remove Arrogant Bastard Posts from Dlang Forum // @namespace http://dlang.bastards.forum // @version0.1 // @description Dlang bastards suck // @match http://forum.dlang.org/* // @requirehttp

Re: Version of implementation for docs

2013-08-11 Thread JS
On Sunday, 11 August 2013 at 10:16:47 UTC, bearophile wrote: JS: Can we get the version of implementation/addition of a feature in the docs. e.g., if X feature/method/library is added into dmd version v, then the docs should display that feature. Python docs do this, and in my first patch I

Re: Variadic grouping

2013-08-11 Thread JS
On Sunday, 11 August 2013 at 08:32:35 UTC, jerro wrote: Group!() and (); are the same except one is shorter and IMO more convienent... there is otherwise, no other difference. Except, of course, the fact that one requires a language change and the other doesn't. and? How many language change

Re: Version of implementation for docs

2013-08-11 Thread JS
On Sunday, 11 August 2013 at 07:17:57 UTC, Jonathan M Davis wrote: On Sunday, August 11, 2013 09:10:15 JS wrote: And where can I download the most up to date compiled dmd for windows? The latest relase is always here: http://dlang.org/download.html And that's the version that the o

Re: Version of implementation for docs

2013-08-11 Thread JS
On Sunday, 11 August 2013 at 07:04:14 UTC, Jonathan M Davis wrote: On Sunday, August 11, 2013 06:30:57 JS wrote: Can we get the version of implementation/addition of a feature in the docs. e.g., if X feature/method/library is added into dmd version v, then the docs should display that feature

Version of implementation for docs

2013-08-10 Thread JS
Can we get the version of implementation/addition of a feature in the docs. e.g., if X feature/method/library is added into dmd version v, then the docs should display that feature. For example, when I go to http://dlang.org/phobos/object.html I see tsize. When I try to use it on my class I dm

Re: Variadic grouping

2013-08-10 Thread JS
On Sunday, 11 August 2013 at 03:14:46 UTC, Timon Gehr wrote: Guys, stop feeding the stupid troll now. He is not worth anyone's time. Yeah, who's the troll? Variadic grouping is useless says the troll.

Re: Variadic grouping

2013-08-10 Thread JS
On Saturday, 10 August 2013 at 18:28:39 UTC, Artur Skawina wrote: On 08/10/13 12:19, John Colvin wrote: On Monday, 29 July 2013 at 13:23:23 UTC, JS wrote: Sometimes it's nice to be able to have groups of variadic parameters: template t(T1..., T2...) ... t!(a, b, c; d, e, f); so that

Re: Eponymous Aggregates

2013-08-10 Thread JS
On Saturday, 10 August 2013 at 22:17:11 UTC, Timon Gehr wrote: On 08/10/2013 10:10 PM, JS wrote: ... This is simply generalizing eponymous templates to interfaces, classes, structs, etc. http://i.imgur.com/u29r8pH.jpg Too bad for you... I already did a few days ago!

Re: Eponymous Aggregates

2013-08-10 Thread JS
On Saturday, 10 August 2013 at 18:28:41 UTC, Simen Kjaeraas wrote: On 2013-08-10, 14:58, JS wrote: e.g., interface A { static T A(T)() { ... } } can be used as A!T instead of A.A!T. Same for classes and structs. If you want a use case I'm not going to stop you from coming up wit

Re: Variadic grouping

2013-08-10 Thread JS
alias T = Tuple!(int, int); alias Ts = Tuple!(T, T); template A(S0..., S1...) { alias s0 = S0; alias s1 = S1; } A!(Ts.init).s0 a; so alias T = Tuple!(int, int); alias Ts = TupleSC!(T, T); then Ts == ((int, int); (int, int)) and alias T = TupleSC!(int, int); alias Ts = Tup

Re: Variadic grouping

2013-08-10 Thread JS
On Saturday, 10 August 2013 at 17:08:57 UTC, John Colvin wrote: On Saturday, 10 August 2013 at 12:40:55 UTC, JS wrote: On Saturday, 10 August 2013 at 10:19:34 UTC, John Colvin wrote: On Monday, 29 July 2013 at 13:23:23 UTC, JS wrote: Sometimes it's nice to be able to have groups of var

Eponymous Aggregates

2013-08-10 Thread JS
e.g., interface A { static T A(T)() { ... } } can be used as A!T instead of A.A!T. Same for classes and structs. If you want a use case I'm not going to stop you from coming up with one... so feel free.

Re: Variadic grouping

2013-08-10 Thread JS
On Saturday, 10 August 2013 at 10:19:34 UTC, John Colvin wrote: On Monday, 29 July 2013 at 13:23:23 UTC, JS wrote: Sometimes it's nice to be able to have groups of variadic parameters: template t(T1..., T2...) ... t!(a, b, c; d, e, f); so that a,b,c are for T1 and d,e,f are for T2.

Re: @property - take it behind the woodshed and shoot it?

2013-08-10 Thread JS
On Thursday, 24 January 2013 at 08:35:01 UTC, Walter Bright wrote: This has turned into a monster. We've taken 2 or 3 wrong turns somewhere. Perhaps we should revert to a simple set of rules. Here is my mindless proposal after reading some of the posts. 1. Properties are data. Cannot be c

Re: UFCS for templates

2013-08-08 Thread JS
On Friday, 9 August 2013 at 00:57:21 UTC, Mike Parker wrote: On Friday, 9 August 2013 at 00:34:31 UTC, JS wrote: Are you not smart enough to come up with use cases yourself? This is not some extremely rare thing that might be used 1 in 10^100. It's not his proposal. The burden of pro

Re: UFCS for templates

2013-08-08 Thread JS
On Thursday, 8 August 2013 at 17:55:04 UTC, Dicebot wrote: On Thursday, 8 August 2013 at 17:35:02 UTC, JS wrote: Can we have UFCS for templates? e.g., T New(T, A...)(A args) { } T t = T.New(args); Note, in this case, the type parameter is substituted. As always, providing motivating use

UFCS for templates

2013-08-08 Thread JS
Can we have UFCS for templates? e.g., T New(T, A...)(A args) { } T t = T.New(args); Note, in this case, the type parameter is substituted.

Re: Question on Interface.

2013-08-07 Thread JS
On Wednesday, 7 August 2013 at 07:11:58 UTC, SteveGuo wrote: I like the concept of interface, It enforces its successors to implement some necessary methods. Please take a look at the following example: device.d - interface device { // I want the three methods i

Re: Designing with the GC out of mind

2013-08-06 Thread JS
On Tuesday, 6 August 2013 at 14:27:32 UTC, Adam D. Ruppe wrote: On Tuesday, 6 August 2013 at 13:43:01 UTC, JS wrote: I'd still like some easy way to hook into the GC to monitor what is going on though because ultimately I'd like to disable the GC but then must guarantee that mem

Re: Phobos and older DMD versions

2013-08-06 Thread JS
On Tuesday, 6 August 2013 at 14:56:43 UTC, Mr. Anonymous wrote: On Tuesday, 6 August 2013 at 14:51:35 UTC, qznc wrote: In my opinion it should, because it makes Phobos development simpler. You don't need a self compiled dmd to fix bugs. On a related note, I think providing compiled daily/weekl

Re: Designing with the GC out of mind

2013-08-06 Thread JS
On Tuesday, 6 August 2013 at 12:41:26 UTC, Adam D. Ruppe wrote: On Tuesday, 6 August 2013 at 07:19:40 UTC, JS wrote: 1. Is there a way to determine what the GC is doing? It is probably easiest to just run it in a debugger, and set a breakpoint on gc_malloc and gc_qalloc. When it breaks, you

Designing with the GC out of mind

2013-08-06 Thread JS
I would like to remove the GC dependence on my own class objects I am designing and at some point remove the GC completely if possible(assuming at some point D itself will be GC agnostic). 1. Is there a way to determine what the GC is doing? I would like to know just how much my projects are G

Re: request switch statement with common block

2013-08-03 Thread JS
On Saturday, 3 August 2013 at 21:42:00 UTC, Walter Bright wrote: On 8/3/2013 12:51 PM, JS wrote: On Saturday, 3 August 2013 at 19:10:19 UTC, Andre Artus wrote: If the implementation is so obviously trivial why don't you implement a proof of concept? because I have better things

Re: request switch statement with common block

2013-08-03 Thread JS
On Saturday, 3 August 2013 at 19:22:53 UTC, Walter Bright wrote: On 8/3/2013 12:00 PM, JS wrote: What I really don't get it is why people think that just because they won't use such a feature then it must be useless to everyone else. You could provide supporting evidence by exami

Re: request switch statement with common block

2013-08-03 Thread JS
On Saturday, 3 August 2013 at 19:10:19 UTC, Andre Artus wrote: On Saturday, 3 August 2013 at 18:56:47 UTC, JS wrote: On Saturday, 3 August 2013 at 17:45:11 UTC, w0rp wrote: I can see you saving a little bit of typing with this, but it's not worth it. Um, it can actually save a lot of

Re: request switch statement with common block

2013-08-03 Thread JS
On Saturday, 3 August 2013 at 18:51:24 UTC, MattCoder wrote: On Saturday, 3 August 2013 at 18:04:03 UTC, Walter Bright wrote: On 8/3/2013 10:45 AM, w0rp wrote: I can see you saving a little bit of typing with this, but it's not worth it. It would be a very unconventional syntactic form, and

Re: request switch statement with common block

2013-08-03 Thread JS
On Saturday, 3 August 2013 at 17:45:11 UTC, w0rp wrote: I can see you saving a little bit of typing with this, but it's not worth it. Um, it can actually save a lot of type and errors. having two places to change is very error prone. if (cond) { } switch(cond) If the condition is complex an

Re: request switch statement with common block

2013-08-03 Thread JS
On Saturday, 3 August 2013 at 16:16:24 UTC, Ary Borenszweig wrote: On 8/3/13 11:38 AM, JS wrote: switch (cond) common: always executed code here case A : etc... } instead of if (cond) { always executed code here } switch (cond) case A : etc... } which requires

request switch statement with common block

2013-08-03 Thread JS
switch (cond) common: always executed code here case A : etc... } instead of if (cond) { always executed code here } switch (cond) case A : etc... } which requires modification of the condition twice when necessary

Re: alias this doesn't work for properties.

2013-08-01 Thread JS
On Friday, 2 August 2013 at 01:46:28 UTC, Jesse Phillips wrote: I'm going to provide a reduced case for the issue you are having. struct Foo { double x; alias x this; } void main() { Foo a; a = 8; // Alias this assignment assert(a.x == 8); fun(7); // What you want } vo

Re: alias this doesn't work for properties.

2013-08-01 Thread JS
On Thursday, 1 August 2013 at 23:51:38 UTC, John Colvin wrote: On Thursday, 1 August 2013 at 22:23:40 UTC, JS wrote: This is wrong because (cast(A)b.Y) = 3; works. That's an interesting case. cast(A)b.Y) is using the B getter property, which makes sense as, due to the cast, nothing

Re: alias this doesn't work for properties.

2013-08-01 Thread JS
On Thursday, 1 August 2013 at 21:56:46 UTC, John Colvin wrote: On Thursday, 1 August 2013 at 20:42:08 UTC, JS wrote: http://dpaste.dzfl.pl/0c923861 class A { double x; @property double X() { return x; } @property double X(double v) { return x = v; } alias X this; } class B { A

alias this doesn't work for properties.

2013-08-01 Thread JS
http://dpaste.dzfl.pl/0c923861 class A { double x; @property double X() { return x; } @property double X(double v) { return x = v; } alias X this; } class B { A a; @property A Y() { return a; } @property A Y(A v) { return a = v; } } void main() { B b = new B

Re: Article on programming language adoption (x-post from /r/programming)

2013-08-01 Thread JS
On Thursday, 1 August 2013 at 17:45:16 UTC, H. S. Teoh wrote: On Thu, Aug 01, 2013 at 10:37:50AM -0700, Walter Bright wrote: On 8/1/2013 9:53 AM, H. S. Teoh wrote: >Y'know, one feature I've always wanted is the equivalent of >preprocessed C code -- with all mixins expanded, aliases >substituted

Re: Dlang code mixin output

2013-07-31 Thread JS
On Wednesday, 31 July 2013 at 13:37:58 UTC, Dicebot wrote: On Wednesday, 31 July 2013 at 13:25:45 UTC, JS wrote: On Wednesday, 31 July 2013 at 13:19:46 UTC, dennis luehring >When you do that with nested templates it > creates a huge mess... also errors are useless... as the point to

Re: Dlang code mixin output

2013-07-31 Thread JS
On Wednesday, 31 July 2013 at 13:19:46 UTC, dennis luehring wrote: Am 31.07.2013 14:35, schrieb JS: On Wednesday, 31 July 2013 at 12:23:42 UTC, dennis luehring wrote: Am 31.07.2013 14:09, schrieb JS: It would be nice to be able to have a precompilation step that produces a d output file that

Re: Dlang code mixin output

2013-07-31 Thread JS
On Wednesday, 31 July 2013 at 12:23:42 UTC, dennis luehring wrote: Am 31.07.2013 14:09, schrieb JS: It would be nice to be able to have a precompilation step that produces a d output file that is the "mixed down" version with all the string mixins computed. This would allow one to l

Dlang code mixin output

2013-07-31 Thread JS
It would be nice to be able to have a precompilation step that produces a d output file that is the "mixed down" version with all the string mixins computed. This would allow one to look at the files, allow better code analysis/error messages, and intellisense and other things to be useful. A

Re: Passing string from D to c++

2013-07-30 Thread JS
On Tuesday, 30 July 2013 at 20:09:01 UTC, Milvakili wrote: On Tuesday, 30 July 2013 at 20:02:51 UTC, Dicebot wrote: On Tuesday, 30 July 2013 at 19:52:44 UTC, Milvakili wrote: I'm linking D with C++ lib.a file. When the C++ function has compatible data types I can call them from D. But when I

Re: Request: Auto string mixin templates

2013-07-30 Thread JS
On Tuesday, 30 July 2013 at 14:49:44 UTC, Dicebot wrote: On Tuesday, 30 July 2013 at 14:39:31 UTC, JS wrote: I seriously don't see the issue ;/ By having some special convention for declaring the template then any user of it should have some inclination. Progress isn't made by dumbin

Re: Allow identical imports

2013-07-30 Thread JS
On Tuesday, 30 July 2013 at 14:31:00 UTC, Kenji Hara wrote: 2013/7/30 Dicebot On Tuesday, 30 July 2013 at 12:29:00 UTC, Daniel Murphy wrote: Please file a bug report: http://d.puremagic.com/issues/ I don't think it is a bug, enhancement request for error message at most. Currently se

Re: Request: Auto string mixin templates

2013-07-30 Thread JS
On Tuesday, 30 July 2013 at 14:18:20 UTC, Kenji Hara wrote: Two years ago I proposed the feature with experimental compiler change, but it was properly rejected. https://github.com/D-Programming-Language/dmd/pull/459 Kenji Hara 2013/7/30 JS On Tuesday, 30 July 2013 at 13:03:47 UTC

Re: Request: Auto string mixin templates

2013-07-30 Thread JS
On Tuesday, 30 July 2013 at 13:03:47 UTC, monarch_dodra wrote: On Tuesday, 30 July 2013 at 12:25:47 UTC, JS wrote: First how does that remove having to type mixin every time? That will *never* happen. Having the keyword *mixin* at call site is important so the caller understand what is

Re: Request: Auto string mixin templates

2013-07-30 Thread JS
On Tuesday, 30 July 2013 at 12:19:06 UTC, nazriel wrote: On Monday, 29 July 2013 at 10:54:37 UTC, JS wrote: I have a template t that returns a string that is always to be used as a mixin. It is quite annoying to have to use mixin() on the template. e.g., mixin(t!()); It would be nice to

Re: Allow identical imports

2013-07-30 Thread JS
On Tuesday, 30 July 2013 at 11:19:37 UTC, Dicebot wrote: On Tuesday, 30 July 2013 at 11:01:07 UTC, JS wrote: On Tuesday, 30 July 2013 at 10:36:15 UTC, Dicebot wrote: You can use scoped local imports and avoid necessity to track global state. Huh? If I follow you, this won't work

Re: Allow identical imports

2013-07-30 Thread JS
On Tuesday, 30 July 2013 at 10:36:15 UTC, Dicebot wrote: You can use scoped local imports and avoid necessity to track global state. Huh? If I follow you, this won't work. I'm generating code so don't have the luxury to mess with the outer scope where the code is going. mixin(code fragment)

Allow identical imports

2013-07-30 Thread JS
I have ctfe generated code which requires generating import statements so symbols can be looked up(avoiding the need to have to manually import modules). 1. Allow identical import statements not throw an error. import std.conv : to; import std.conv : to; throws error Error 1 Error: alias main

Re: Variadic grouping

2013-07-30 Thread JS
On Monday, 29 July 2013 at 15:02:13 UTC, Robert Clipsham wrote: On Monday, 29 July 2013 at 14:46:02 UTC, Robert Clipsham wrote: You can achieve this like so: template Outer(T...) { template Inner(U...) { // Do something with T and U } } Outer!(a, b, c).Inner!(d, e, f); Yo

Re: Variadic grouping

2013-07-29 Thread JS
On Monday, 29 July 2013 at 17:28:57 UTC, Meta wrote: On Monday, 29 July 2013 at 17:22:50 UTC, JS wrote: I'm not sure how named parameters would solve the original problem Your original use case: template t(T1..., T2...) ... t!(a, b, c; d, e, f); Becomes //Some weird hypothetical s

Re: Variadic grouping

2013-07-29 Thread JS
On Monday, 29 July 2013 at 16:52:17 UTC, Meta wrote: On Monday, 29 July 2013 at 16:02:02 UTC, monarch_dodra wrote: Except for this... alias K = Select!(true, 4, int); ;) Useful? I don't think so... but I thought I'd point it out ^^ I think it's a feature that this doesn't work. As for variad

Re: Variadic grouping

2013-07-29 Thread JS
On Monday, 29 July 2013 at 13:59:54 UTC, bearophile wrote: JS: The usefulness should be obvious and I seriously doubt if someone thinks it is not then any example I could give would convince them otherwise. It's not obvious for me :-) Explaining the "obvious" is sometimes ne

Re: Variadic grouping

2013-07-29 Thread JS
On Monday, 29 July 2013 at 13:30:58 UTC, bearophile wrote: JS: I doubt such a feature will ever get added but who knows... It seems a cute idea, but why don't you show two or more very different use cases? (Asking for a feature without showing use cases is not so good.) Bye, bearo

Variadic grouping

2013-07-29 Thread JS
Sometimes it's nice to be able to have groups of variadic parameters: template t(T1..., T2...) ... t!(a, b, c; d, e, f); so that a,b,c are for T1 and d,e,f are for T2. This can be done by making a symbol and breaking up a single variadic but is messy. I doubt such a feature will ever get

Request: Auto string mixin templates

2013-07-29 Thread JS
I have a template t that returns a string that is always to be used as a mixin. It is quite annoying to have to use mixin() on the template. e.g., mixin(t!()); It would be nice to be able to specify that the template is mixed in at the call site. e.g., string mixin template t() { ... }

Re: Are we getting better at designing programming languages?

2013-07-27 Thread JS
On Friday, 26 July 2013 at 23:19:45 UTC, H. S. Teoh wrote: On Fri, Jul 26, 2013 at 03:02:32PM +0200, JS wrote: I think the next step in languages it the mutli-level abstraction. Right now we have the base level core programming and the preprocessing/template/generic level above that. There is

Re: Compile-time optimization

2013-07-26 Thread JS
oops, that was a mess... I guess I need to learn how to program. This one is not much better but at least works. I'll have to rewrite the code. module main; import std.stdio, std.traits; template tuple(args...) { alias tuple = args; } template tUnrollArgs(args...) { pragma(msg,

Re: Compile-time optimization

2013-07-26 Thread JS
The following code works better. Forgot to allow for multiple arguments. Runtime variables are not unrolled though but I'll work on understanding how you were able to unify the two as one(I think in your reduceImpl). module main; import std.stdio, std.traits; template tuple(args...) { al

Re: Are we getting better at designing programming languages?

2013-07-26 Thread JS
I think the next step in languages it the mutli-level abstraction. Right now we have the base level core programming and the preprocessing/template/generic level above that. There is no reason why language can't/shouldn't keep going. The ability to control and help the compiler do it's job bett

Re: Compile-time optimization

2013-07-25 Thread JS
Thanks.. I am working on getting the code to work with unrolling an array: module main; import std.stdio, std.traits; template tuple(args...) { alias tuple = args; } template tUnrollArray(args...) { static if (isArray!(typeof(args))) { pragma(msg, "isarray

Re: Compile-time optimization

2013-07-25 Thread JS
On Wednesday, 24 July 2013 at 19:52:57 UTC, H. S. Teoh wrote: On Wed, Jul 24, 2013 at 08:12:36PM +0200, JS wrote: T, I've looked over your code and understand what you are doing but I don't understand the expression is(typeof(func(args[0], args[1] you are checking if f

Re: Compile-time optimization

2013-07-24 Thread JS
On Wednesday, 24 July 2013 at 18:12:37 UTC, JS wrote: T, Also, I've tried to wrap the template in a function and I can't get it to work: string join(T...)(string delim, T args) { return tupleStringReduce!(args); } it seems tupleSt

Re: Compile-time optimization

2013-07-24 Thread JS
T, I've looked over your code and understand what you are doing but I don't understand the expression is(typeof(func(args[0], args[1] you are checking if func(a,b)'s return type is a type?

Re: Compile-time optimization

2013-07-24 Thread JS
On Wednesday, 24 July 2013 at 09:58:02 UTC, monarch_dodra wrote: On Wednesday, 24 July 2013 at 09:56:41 UTC, monarch_dodra wrote: version (poop) Goddamnit. There goes my credibility -_-' I was testing to see if I got a compile error with an inexistant version tag. Please replace that with

Re: Compile-time optimization

2013-07-24 Thread JS
On Wednesday, 24 July 2013 at 01:07:15 UTC, H. S. Teoh wrote: On Wed, Jul 24, 2013 at 01:35:23AM +0200, JS wrote: [...] My three points out of the post is: 1. D needs some way to make doing this stuff easier. 2. It needs to be done! ;) 3. Goto 1. I didn't realize D could even potential

Re: Compile-time optimization

2013-07-23 Thread JS
On Tuesday, 23 July 2013 at 22:38:35 UTC, Yota wrote: On Tuesday, 23 July 2013 at 20:11:21 UTC, JS wrote: Your code doesn't exactly do what I wanted but probably because I wasn't clear... I think it is modifiable and solves the problem I was having(again, assuming your code is correc

Re: Compile-time optimization

2013-07-23 Thread JS
On Tuesday, 23 July 2013 at 19:59:46 UTC, H. S. Teoh wrote: On Tue, Jul 23, 2013 at 12:42:18PM -0700, H. S. Teoh wrote: [...] With the help of the new tupleReduce, you can do all sorts of compile-time optimizations. [...] Here's an example of how to implement compile-time optimization of joi

Compile-time optimization

2013-07-23 Thread JS
There seems to be a lot of improvement for programming languages to optimize compile time aspects that are not taken into account. With ctfe I think such optimizations are more and more relevant in D. I'll give a simple example: Take a standard string joining function: string join(string[] s

Re: Closures and loop scope

2013-07-23 Thread JS
On Tuesday, 4 June 2013 at 19:19:57 UTC, Idan Arye wrote: Consider the following code. What will it print? auto arr=new ulong delegate()[5]; foreach(i;0..arr.length){ arr[i]=()=>i; } writeln(arr.map!`a()`()); It is natural to expect that it will print [0, 1, 2, 3, 4],

Re: Proof that D sucks!

2013-07-21 Thread JS
On Sunday, 21 July 2013 at 12:56:06 UTC, David wrote: Am 21.07.2013 14:49, schrieb JS: Ok, don't get your panties in a wad! Calm down, go grab a beer, change your britches and take your high blood meds! I'm just joking... And I was expecting the monthly D rant and why it sucks. Too

Proof that D sucks!

2013-07-21 Thread JS
Ok, don't get your panties in a wad! Calm down, go grab a beer, change your britches and take your high blood meds! I'm just joking...

Re: Request: nested enums

2013-07-16 Thread JS
If one want's to avoid that problem, just don't allow the nested enum also have a value. It's not a huge deal but just a sort of alias this concept applied to enums: enum A { default, a, b, c; alias a this; }

Re: Request: nested enums

2013-07-16 Thread JS
On Tuesday, 16 July 2013 at 15:50:54 UTC, Yota wrote: On Monday, 15 July 2013 at 13:47:21 UTC, JS wrote: Here is a better example that can actually be implemented but not pretty: final immutable struct Msg { immutable int Foo = 0; immutable int Bar = 1; final immutable struct Type

Re: Request: nested enums

2013-07-15 Thread JS
Here is a better example that can actually be implemented but not pretty: final immutable struct Msg { immutable int Foo = 0; immutable int Bar = 1; final immutable struct Type { immutable int Error = 1; immutable int Ok = 10001; } } Here type is not ne

Request: nested enums

2013-07-15 Thread JS
I think it would be nice to have such a feature: enum A { a, b, c enum B { d, e, f } } this helps with logically nested types. Possibly A.B returns the first(or possibly default) entry of the list(d). Also, a useful property would be to uniformly distribute the enums insid

Name resolution in templates issue

2013-07-13 Thread JS
I believe this is a flaw in template design, maybe intentional or overlooked or possibly my own lack of knowledge. I have a module with templates in it. I use these templates to built up compile time constructs such as methods, properties, and fields for various things like classes and interfa

Bug: Crash: nested interfaces

2013-07-13 Thread JS
module main; import std.stdio, std.cstream; interface A : A.B { interface B { } } int main(string[] argv) { return 0; } One can argue about the validity of the code, I tried it to created logical heirarchy of interfaces. e.g., instead of interface Name : NameExtension; interface

moduleName bug

2013-07-12 Thread JS
Module name doesn't seem to work with qualified module names. I imagine this also is an issue with other similar functions: template moduleName(alias T) { static assert(!T.stringof.startsWith("package "), "cannot get the module name for a package"); static if (T.stringof.startsWith("

Re: Memory management design

2013-07-10 Thread JS
On Wednesday, 10 July 2013 at 10:56:48 UTC, Paulo Pinto wrote: On Wednesday, 10 July 2013 at 10:40:10 UTC, JS wrote: On Wednesday, 10 July 2013 at 09:06:10 UTC, Paulo Pinto wrote: On Wednesday, 10 July 2013 at 08:00:55 UTC, Manu wrote: On 10 July 2013 17:53, Dicebot wrote: On Wednesday, 10

Re: Memory management design

2013-07-10 Thread JS
On Wednesday, 10 July 2013 at 10:49:04 UTC, Dicebot wrote: On Wednesday, 10 July 2013 at 10:40:10 UTC, JS wrote: ... @nogc itself does not help here as this code will still be affected by stop-the-world. Those issues are related, but not directly. It will help to avoid memory leaks when

Re: Memory management design

2013-07-10 Thread JS
On Wednesday, 10 July 2013 at 09:06:10 UTC, Paulo Pinto wrote: On Wednesday, 10 July 2013 at 08:00:55 UTC, Manu wrote: On 10 July 2013 17:53, Dicebot wrote: On Wednesday, 10 July 2013 at 07:50:17 UTC, JS wrote: ... I am pretty sure stuff like @nogc (or probably @noheap. or both) will

Re: Memory management design

2013-07-10 Thread JS
On Tuesday, 9 July 2013 at 23:32:13 UTC, BLM768 wrote: Given all of this talk about memory management, it would seem that it's time for people to start putting forward some ideas for improved memory management designs. I've got an idea or two of my own, but I'd like to discuss my ideas before I

Re: access CTFE variables at compile time.

2013-07-09 Thread JS
On Wednesday, 10 July 2013 at 01:10:37 UTC, Meta wrote: On Tuesday, 9 July 2013 at 22:49:38 UTC, JS wrote: It seems possible that we can print CTFE variables at compile time by using string mixes as the code below demonstrates. The problem is that we can not pass a variable to a template to

access CTFE variables at compile time.

2013-07-09 Thread JS
It seems possible that we can print CTFE variables at compile time by using string mixes as the code below demonstrates. The problem is that we can not pass a variable to a template to create a print routine in the first place. e.g., we can't do mixin a!(s) if s is a string since s can't be re

Re: Function literals can't be class members

2013-07-09 Thread JS
On Tuesday, 9 July 2013 at 10:25:26 UTC, John Colvin wrote: On Monday, 8 July 2013 at 22:41:41 UTC, JS wrote: trying to use a lambda inside a sub template gives an error. mixin template a { template b() { enum b = { }(); } mixin(b!()); } gives the error in the subject, removing

Re: Function literals can't be class members

2013-07-09 Thread JS
On Tuesday, 9 July 2013 at 10:10:10 UTC, Dicebot wrote: On Tuesday, 9 July 2013 at 09:44:17 UTC, JS wrote: Anyone have any ideas? Yes and I will answer once you start asking question in D.learn newsgroup. Thanks... I'll just keep posting in here then...

Re: Function literals can't be class members

2013-07-09 Thread JS
On Monday, 8 July 2013 at 22:41:41 UTC, JS wrote: trying to use a lambda inside a sub template gives an error. mixin template a { template b() { enum b = { }(); } mixin(b!()); } gives the error in the subject, removing the nesting or using a function instead of a lamda

Re: What the heck is wrong with CTFE's?

2013-07-08 Thread JS
On Monday, 8 July 2013 at 23:36:46 UTC, John Colvin wrote: On Monday, 8 July 2013 at 22:57:17 UTC, JS wrote: int i = 0; foreach(t; T) { string name = "Value"~((i==0) ? "" : (to!string(i))); i++; } That increme

Re: What the heck is wrong with CTFE's?

2013-07-08 Thread JS
Ultimately, the point is, that I thought CTFE's were suppose to be compile time runnable functions. The problem is, the actual language grammar changes. can use i++ as an argument to a template at runtime without issue but not at compile time... and since this seems to be the case from the exam

Re: What the heck is wrong with CTFE's?

2013-07-08 Thread JS
On Monday, 8 July 2013 at 12:11:36 UTC, Dicebot wrote: On Monday, 8 July 2013 at 12:08:44 UTC, JS wrote: the issue with the foreach is still under question though, when I try to use a for loop with i and access TT[i] I get an error about i not being compile time readable. (maybe this is

Function literals can't be class members

2013-07-08 Thread JS
trying to use a lambda inside a sub template gives an error. mixin template a { template b() { enum b = { }(); } mixin(b!()); } gives the error in the subject, removing the nesting or using a function instead of a lamda produces no error, yet all are essentially semantically

Re: What the heck is wrong with CTFE's?

2013-07-08 Thread JS
On Monday, 8 July 2013 at 12:09:55 UTC, Dicebot wrote: P.S. you speak about (i == 0) but your snippet has (i > 0) Thats simply because I forgot to change it.. I tried various things... it's not relevant... the problem is back... when I remove the compare on i name is updated, when I don' t

Re: What the heck is wrong with CTFE's?

2013-07-08 Thread JS
On Monday, 8 July 2013 at 12:03:52 UTC, JS wrote: On Monday, 8 July 2013 at 11:56:40 UTC, JS wrote: The following code inserts properties for each type, auto name = "Value"~((i == 0) ? "" : to!string(i++)); always as the i == 0 evaluate to true. 1. obviously ints work be

Re: What the heck is wrong with CTFE's?

2013-07-08 Thread JS
On Monday, 8 July 2013 at 11:56:40 UTC, JS wrote: The following code inserts properties for each type, auto name = "Value"~((i == 0) ? "" : to!string(i++)); always as the i == 0 evaluate to true. 1. obviously ints work because the code below works with i as a count

  1   2   >